home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 November / Chip 11-96.iso / workshop / howto / printing < prev    next >
Text File  |  1996-05-25  |  117KB  |  2,626 lines

  1.                        The Linux Printing-HOWTO
  2.  
  3.                A guide to printing and previewing files
  4.                under the Linux operating system.
  5.  
  6.          Copyright (C) 1994 by Grant Taylor and Brian McCauley
  7.  
  8. Contents
  9. --------
  10.  
  11. 1 Intro
  12. 2 Printing software
  13. 2.1 text
  14. 2.2 pr
  15. 2.3 PostScript
  16. 2.4 fonts
  17. 2.5 faxing
  18. 2.6 *roff, man pages
  19. 2.7 Printing text via PostScript
  20. 2.7.1 mpage
  21. 2.7.2 a2ps
  22. 2.7.3 enscript
  23. 2.7.4 gslp
  24. 2.8 PostScript utilities
  25. 2.9 TeX/dvi
  26. 2.9.1 `dvips'
  27. 2.9.2 `eps'
  28. 2.9.3 `dvilj'
  29. 2.10 texinfo
  30. 2.11 Printing though a terminal
  31. 2.12 hardware and drivers
  32. 2.13 Printer device names
  33. 3 LPR
  34. 3.1 Setting up print services
  35. 3.1.1 Remote Printing Vs. Local Printing
  36. 3.1.2 What You Need
  37. 3.1.3 How Printing Works Under Linux
  38. 3.1.4 The important programs
  39. 3.1.5 The `lpr' Command
  40. 3.1.6 The `lpq' Command
  41. 3.1.7 The `lprm' Command
  42. 3.1.8 The `lpc' Command
  43. 3.1.9 The Important Directories
  44. 3.1.10 The Important Files
  45. 3.1.11 More About /etc/printcap
  46. 3.1.12 Fields in `/etc/printcap'
  47. 3.1.13 More on The `lp' Field
  48. 3.1.14 More On The lf Field
  49. 3.1.15 More On The if Field
  50. 3.1.16 More On The `rm' and `rp' Fields
  51. 3.1.17 More On The `sh' and `sf' Fields
  52. 3.1.18 More On The `mx' Field
  53. 3.1.19 A Test Printcap Entry
  54. 3.1.20 Putting It All Together
  55. 3.1.21 More On Remote Printing
  56. 3.1.22 The Fiddly Bits
  57. 3.1.23 Troubleshooting
  58. 3.2 What lpr and lpd do
  59. 3.3 Getting hold of lpd
  60. 3.4 Where Do The Files Go And What Should Their Permissions Be?
  61. 3.5 lpd not working
  62. 3.6 Where Do I Get A Printcap For Printer Model xxxxx?
  63. 3.7 The Semantics of `/etc/printcap'
  64. 3.8 The Syntax of `/etc/printcap'
  65. 3.9 An `/etc/printcap' gotcha
  66. 3.10 The Minimum /etc/printcap
  67. 3.11 How to prevent the `Staircase Effect'
  68. 3.12 Resetting the printer between each file printed
  69. 3.13 Preventing formfeed after each file printed
  70. 3.14 Printing with lpd to a serial port
  71. 3.15 cat works to the serial port, but not lpd (1)
  72. 3.16 Printers that are not simple devices
  73. 3.17 Generating burst or banner pages
  74. 3.18 Spooling text to a PostScript printer
  75. 3.19 Why graphics files are sometines truncated
  76. 3.20 Why `lpr -i' doesn't work
  77. 3.21 Why `lpr -p' doesn't work?
  78. 3.22 `lpc' and `lpq' warning of missing daemons
  79. 3.23 Using `lpr' over a network
  80. 3.24 Writing lpd filters
  81. 3.25 Debuging lpd filters
  82. 3.26 Output (`of') filters
  83. 3.27 Getting filters for given printers
  84. 3.28 Filters from programs that won't read STDIN
  85. 3.29 Having many filters
  86. 3.30 Magic Filters
  87. 3.31 Magic Filter Examples
  88. 4 Previewing
  89. 4.1 ghostview
  90. 4.2 gspreview
  91. 4.3 xdvi
  92. 4.4 xtex
  93. 4.5 gxditview
  94. 4.6 non-X previewing
  95. 5 Ascii Translation
  96. 5.1 from TeX
  97. 5.2 from dvi
  98. 5.3 from PostScript
  99. 5.4 from troff
  100. 5.5 from ascii/latin1
  101.  
  102. 1 Intro
  103. *******
  104.  
  105.    This is the Printing HOWTO for Linux.  This is a member of the second
  106. generation of Linux FAQs.  The original Linux FAQ gradually became a
  107. monolithic beast, and has now been re-written in a new syle, refering to
  108. HOWTOs for details.  This HOWTO details how to properly set up most
  109. types of printers, how to configure software to make them print well,
  110. what types of fax software are available, and how to preview many types
  111. of printable output. It was originally written by Grant Taylor
  112. <gtaylor@cs.tufts.edu> and later incorporated the lpd-FAQ by Brian
  113. McCauley <B.A.McCauley@bham.ac.uk>. Other HOWTOs detail networking,
  114. kernel hacking, etc.  All HOWTOs are found in several places, the
  115. official location being:
  116. `sunsite.unc.edu:/pub/Linux/docs/HOWTO'
  117.  
  118.    Like just about any usenet FAQs they can also be found on
  119. `rtfm.mit.edu'.
  120.  
  121.    Please send comments, bug reports, etc, to
  122. <printing@god.ext.tufts.edu>.  This address goes to both Brian and
  123. Grant.
  124.  
  125.    If you know anything or can point us towards any useful programs not
  126. in this document that should be, please let us know!
  127.  
  128.    Grant has a mail server set up on his machine.  It stores documents
  129. and other things related to printing and previewing with Linux,
  130. including the latest and greatest version of this document. At some
  131. point in the future this will probably be superceded by our own
  132. directory on one of the major ftp servers. Mail to
  133. <listserv@god.ext.tufts.edu> with a body of `info' will have you sent a
  134. list of available files.  A body of `get file1 [file2 file3... ]' will
  135. send you specific files.
  136.  
  137.    Summary of changes
  138.  
  139.    * Now in texinfo! Available from sunsite in texinfo, dvi and text
  140.      forms. The info form may be read in emacs but less you are a real
  141.      emacsphile or don't have X then you'd probably be better off using
  142.      `tkinfo'.
  143.  
  144.      `tkinfo' is available by anonymous ftp from:
  145.      `ptolemy.eecs.berkeley.edu:pub/misc'
  146.      `harbor.ecn.purdue.edu:pub/tcl/code'
  147.  
  148.      The ptolemy site will always have the latest version.
  149.  
  150.    * New mailserver info.
  151.  
  152.    * Much dead-wood removed.
  153.  
  154.    * Attributions on individual sections do not appear in the final
  155.      version although they do in the texinfo source.
  156.  
  157.    * Assorted little changes
  158.  
  159.    * Incorporated Karl Auer's <Karl.Auer@anu.edu.au> document. This is
  160.      still not seemless so you'll likely find some duplication and
  161.      missing cross references - please let us know.
  162.  
  163. 2 Printing software
  164. *******************
  165.  
  166.    These sections describe printing software known to be available for
  167. Linux.  Note that most Un*x printing software can be easily compiled
  168. under Linux.
  169.  
  170. 2.1 text
  171. ========
  172.  
  173.    Under Linux, or under most any Un*x operating system, the easiest
  174. thing to print with most printers is plain ASCII.  Any way you can
  175. arrange to send the text to the printer is perfectly valid.  If you
  176. have a serial printer, then try devices `/dev/ttyS?', `/dev/ttys?',
  177. `/dev/cua?', etc, and if you have a regular parallel hookup, use
  178. `/dev/lp?'.  Typing `cat FILE >/dev/????' should do it.  You may need
  179. root privileges, or you may wish to chmod your printer device if this
  180. is all you ever print.  (Note the security hole there if you've more
  181. than one user) Some printers (ie, HP DeskJet) want dos-style end of
  182. lines: newline+carriage return.  These printers will show the
  183. 'staircase effect'. See Also: The staircase effect.
  184.  
  185. 2.2 pr
  186. ======
  187.  
  188.    Most plain ascii files in the un*x world have a tendency to be just
  189. that - plain, unformatted ascii with no page breaks or anything else to
  190. make a printed copy look nice and not have lines printed over
  191. perferations.  The answer to this problem is to run your text through a
  192. formatter such as pr.  Pr is a standard un*x utility designed to format
  193. plain text for printing on a line printer.  The usual appearance of the
  194. resulting formatted text has a header and/or footer, page numbers, the
  195. date, possibly margins, double spacing, etc.  As is common with un*x
  196. utils, pr has a bazillion options.  They are detailed in the man page.
  197.  
  198. 2.3 PostScript
  199. ==============
  200.  
  201.    Printing almost anything other than plain text under Un*x usually
  202. involves the ability to print PostScript.  If you have a PostScript
  203. printer, you're all set.  But for most, this is not so easy.
  204.  
  205.    The established way to interpret PostScript under Linux is to use
  206. ghostscript, which, like nearly everything else, comes from the GNU
  207. project.  Ghostscript is a PostScript interpreter which accepts
  208. PostScript input and generates output appropriate for X displays, most
  209. printers, some specialized display hardware, and fax software.
  210.  
  211.    The following devices are available as of ghostscript 2.6.1pl4:
  212.              linux   PC vga using linux svgalib
  213.      #       x11     X Windows version 11, release >=4   [Unix and VMS only]
  214.      # Printers:
  215.      # *     appledmp  Apple Dot Matrix Printer (Imagewriter)
  216.      #       bj10e   Canon BubbleJet BJ10e
  217.      # *     bj200   Canon BubbleJet BJ200
  218.      # *     cdeskjet  H-P DeskJet 500C with 1 bit/pixel color
  219.      # *     cdjcolor  H-P DeskJet 500C with 24 bit/pixel color and
  220.      #               high-quality color (Floyd-Steinberg) dithering
  221.      # *     cdjmono  H-P DeskJet 500C printing black only
  222.      # *     cdj500  H-P DeskJet 500C (same as cdjcolor)
  223.      # *     cdj550  H-P DeskJet 550C
  224.      # *     declj250  alternate DEC LJ250 driver
  225.      # +     deskjet  H-P DeskJet and DeskJet Plus
  226.      # *     dfaxhigh  DigiBoard, Inc.'s DigiFAX software format
  227.      # *     dfaxlow  DigiFAX low (normal) resolution
  228.      #       djet500  H-P DeskJet 500
  229.      # *     djet500c  H-P DeskJet 500C
  230.      #       epson   Epson-compatible dot matrix printers (9- or 24-pin)
  231.      # +     eps9high  Epson-compatible 9-pin, interleaved lines
  232.      #               (triple resolution)
  233.      # *     epsonc  Epson LQ-2550 and Fujitsu 3400/2400/1200 color printers
  234.      # *     escp2   Epson ESC/P 2 language printers, including Stylus 800
  235.      # +     ibmpro  IBM 9-pin Proprinter
  236.      # *     jetp3852  IBM Jetprinter ink-jet color printer (Model #3852)
  237.      # +     laserjet  H-P LaserJet
  238.      # *     la50    DEC LA50 printer
  239.      # *     la75    DEC LA75 printer
  240.      # *     lbp8    Canon LBP-8II laser printer
  241.      # *     ln03    DEC LN03 printer
  242.      # *     lj250   DEC LJ250 Companion color printer
  243.      # +     ljet2p  H-P LaserJet IId/IIp/III* with TIFF compression
  244.      # +     ljet3   H-P LaserJet III* with Delta Row compression
  245.      # +     ljet4   H-P LaserJet 4 (defaults to 600 dpi)
  246.      # +     ljetplus  H-P LaserJet Plus
  247.      # *     m8510   C.Itoh M8510 printer
  248.      # *     necp6   NEC P6/P6+/P60 printers at 360 x 360 DPI resolution
  249.      # *     nwp533  Sony Microsystems NWP533 laser printer   [Sony only]
  250.      # *     oki182  Okidata MicroLine 182
  251.      #       paintjet  H-P PaintJet color printer
  252.      # *     pj      alternate PaintJet XL driver
  253.      # *     pjxl    H-P PaintJet XL color printer
  254.      # *     pjxl300  H-P PaintJet XL300 color printer
  255.      # *     r4081   Ricoh 4081 laser printer
  256.      # *     sparc   SPARCprinter
  257.      # *     t4693d2  Tektronix 4693d color printer, 2 bits per R/G/B component
  258.      # *     t4693d4  Tektronix 4693d color printer, 4 bits per R/G/B component
  259.      # *     t4693d8  Tektronix 4693d color printer, 8 bits per R/G/B component
  260.      # *     tek4696  Tektronix 4695/4696 inkjet plotter
  261.      #%*     trufax  TruFax facsimile driver  [Unix only]
  262.      # File formats and others:
  263.      #       bit     A plain "bit bucket" device
  264.      #       bmpmono Monochrome MS Windows .BMP file format
  265.      #       bmp16   4-bit (EGA/VGA) .BMP file format
  266.      #       bmp256  8-bit (256-color) .BMP file format
  267.      #       bmp16m  24-bit .BMP file format
  268.      #       gifmono Monochrome GIF file format
  269.      #       gif8    8-bit color GIF file format
  270.      #       pcxmono Monochrome PCX file format
  271.      #       pcxgray 8-bit gray scale PCX file format
  272.      #       pcx16   Older color PCX file format (EGA/VGA, 16-color)
  273.      #       pcx256  Newer color PCX file format (256-color)
  274.      #       pbm     Portable Bitmap (plain format)
  275.      #       pbmraw  Portable Bitmap (raw format)
  276.      #       pgm     Portable Graymap (plain format)
  277.      #       pgmraw  Portable Graymap (raw format)
  278.      #       ppm     Portable Pixmap (plain format)
  279.      #       ppmraw  Portable Pixmap (raw format)
  280.      # *     tiffg3  TIFF/F (G3 fax)
  281.  
  282.    Lines beginning with a `#' are drivers included with the gs261
  283. source distribution.
  284.  
  285.    Drivers marked with `%' require commercial software to work
  286.  
  287.    Installations of ghostscript are available from several places:
  288.  
  289.    A full, and presumably correct, installation comes with most
  290. distributions.  Note that this binary installation may require
  291. `libX.so.???', as it includes the X11 display driver.
  292.  
  293.    The "official" installation is to obtain the sources and build it
  294. yourself:
  295.  
  296.    `prep.ai.mit.edu:/pub/gnu/ghostscript-xxxx.tar.gz'
  297. `prep.ai.mit.edu:/pub/gnu/ghostscript-fonts-xxxx.tar.gz'
  298.  
  299.    This is probably best, as you can get the latest version (currently
  300. 2.6.1pl4 (the four patches are separate, they are available from my
  301. mail-server as `gs261-patches')).
  302.  
  303.    A patch which uses the Linux svgalib, and hence does not require X
  304. for previewing is available. See Also: non-X previewing.
  305.  
  306.    A minimal binary installation of ghostscript and several other
  307. packages needed for printing the Linux documentation is available as:
  308. `sunsite.unc.edu:/pub/Linux/apps/tex/texmin/texmin-0.1.tar.z'.
  309.  
  310.    Note that this does not contain any PostScript fonts.  (Nor do you
  311. need them to print dvi (aka [La]TeX).)
  312.  
  313.    The main Ghostscript documentation is contained in the file
  314. `use.doc', either in the source directory, or
  315. `lib/ghostscript/doc/use.doc' if you haven't the sources.
  316.  
  317.    To print ps, first determine your driver name with `gs -help' which
  318. lists installed drivers.  If the device you need is not listed, you
  319. must compile gs yourself from the source distribution (do not panic.
  320. Do follow the instructions in make.doc.  You will need 5 or 6 megs of
  321. space to build it in.)  Then type `gs -dNOPAUSE -sDEVICE=??????
  322. -sOutputFile=/dev/???? file.ps' and your output should (hopefully)
  323. appear at your printer.  Those of you with non-US paper sizes may wish
  324. to build gs yourself with the right default, or you may use the
  325. `-sPAPERSIZE=a4' option.
  326.  
  327.    Ghostscript may be used to print at most of the resolutions your
  328. printer supports; `-r300', `-r150', `-r360x180' are examples of the
  329. option used to control this.  Dot matrix printers in particular need to
  330. choose an appropriate resolution, since they do not typically run at
  331. the more standard 300dpi.  Note that versions 2.6 and greater of
  332. ghostscript have more drivers.
  333.  
  334. 2.4 fonts
  335. =========
  336.  
  337.    (This section contains font information not specific to any
  338. ghostscript driver, nor even specific to ghostscript).  Font
  339. information pertaining to the X11 `gs' drivers (and thus to ghostview)
  340. is included in the ghostview section under previewing)
  341.  
  342.    All versions of ghostscript come with assorted public-domain fonts,
  343. most of which were generated from bitmaps, and are therefore of
  344. relatively poor quality.  However, ghostscript can use any PostScript
  345. Type 1 or 3 fonts you may have handy.  For example, the Adobe Type
  346. Manager (for any platform other than mac) comes with fonts you can use.
  347. Place the fonts (typically *.pc?) in `lib/ghostscript/fonts/' and add
  348. to `lib/ghostscript/Fontmap' lines such as:
  349.  
  350.      /Courier             (com_____.pfb) ;
  351.  
  352.    A full fontmap file for the ususal set of fonts included with the
  353. Adobe Type Manager is available as `fontmap.atm' from the printing
  354. mailserver.
  355.  
  356.    TimesNewRomanPS and ArialMT fonts are interchangable with Times Roman
  357. and Helvetica, so you can alias them this way if this is what you have.
  358.  
  359.    Adobe Type 1 fonts may be found on the net in several places:
  360. `ftp.cica.indiana.edu:/pub/pc/win3/fonts'
  361. `archive.umich.edu:/msdos/mswindows/fonts'
  362.  
  363.    I have not looked in these places, but this information is lifted
  364. straight from the comp.fonts FAQ (which you should read if fonts are a
  365. thing for you.  You can get a copy of this from `rtfm.mit.edu').
  366.  
  367.    Conversion between various font types is tricky.  Ghostscript comes
  368. with the tools needed to take a bitmap (hopefully large) and make a
  369. scalable ps font.  Groff comes with the tools to allow use of tfm/mf
  370. (TeX) and pfb (Type 1) fonts in *roff documents.  X11R5 includes
  371. several font utilities and Type 1 rendering code contributed by IBM.  I
  372. have used none of the above, but they all come with manpages, so read
  373. them.  Other font conversion utilities are listed in the comp.fonts
  374. FAQ.  Also look into the package fontutils on
  375. `prep.ai.mit.edu:/pub/gnu/'.
  376.  
  377. 2.5 faxing
  378. ==========
  379.  
  380.    If you have a fax modem, you can arrage to fax things out (and in),
  381. including PostScript, dvi, ascii, etc...  Arranging for e-mail to fax
  382. itself somewhere is also straightforward.
  383.  
  384.    Fax modems support one of of two cammand sets: Class 1 or 2.  Class
  385. one modems are have less of what goes on in a fax supported in firmware
  386. (thus the software has to do more.  Supporting such timing-critical
  387. things under a preemptive multitasking environment like Linux is tricky
  388. at best).  The class 1 standard is EIA 578.  Class 2 modems tend to be
  389. more expensive and comply with the standard EIA 592.  Mention of your
  390. fax modem's level of support should be in its manuals.  Do not confuse
  391. class and group.  You will, of course, want a group III fax modem.
  392.  
  393.    Fax software which runs under Linux must convert input in whatever
  394. format into a Group III compatible image format for transmission.  As
  395. usual, Ghostscript does the job.  The device tiffg3 generates standard
  396. g3/tiff encoded fax messages.  You must compile this device in if it is
  397. not there already; this is yet another reason to get the source.  Some
  398. fax sofware on commercial platforms can use the display PostScript
  399. renderer to render the fax image; this is not yet an option under Linux.
  400.  
  401.    The GNU program netfax supports Class 2 fax modems only.  It builds
  402. nearly out of the box under linux.  I have patches for version 3.2.1;
  403. you can get them from the printing mail server as `netfaxpatch'.  It
  404. runs a server and accepts jobs into a queue from the local machine and
  405. the net.  Netfax is in use at MIT.  It accepts PostScript, dvi, and
  406. ascii, and can be configured to work as an email gate.  Documentation
  407. in the package is limited to compile notes and man pages for the
  408. individual programs; actual installation tips are few and far between.
  409. `prep.ai.mit.edu:/pub/gnu/fax-3.2.1.tar.gz'
  410.  
  411.    FlexFax is available from:
  412. `sgi.com(192.48.153.1):/sgi/fax/?????.src.tar.Z'
  413.  
  414.    It is written in C++, and thus requires g++ to build.  FlexFax
  415. supports class 1 and 2 modems, uses ghostview (or a display PostScript
  416. server) for rendering, and generally is more complete, or at least
  417. general than the somewhat MIT-specific netfax.  It also can run in
  418. place of getty and either receive a fax or spawn a login as appropriate
  419. for the type of call.  It includes precise instructions on configuring
  420. smail3, sendmail, and other mail agents to send mail for
  421. so-and-so@12345678.fax to the fax at 12345678.  This is the package I
  422. recommend if you have real faxing needs, as it is properly documented
  423. and full-featured.  Version 2.x of FlexFax is in real release now and
  424. fully supports Linux - just type `./configure' and `make'.
  425.  
  426.    mgetty+sendfax is a Linux and SCO-specific getty for faxmodems and a
  427. simple sendfax program.  This package is available as
  428. `sunsite.unc.edu:/pub/Linux/system/Serial/mgetty+sendfax-0.16.tar.gz'.
  429. This is a good package for those who need to send a fax every now and
  430. then.
  431.  
  432.    Finally, `efax' deserves mention.  Class 2 only.  no net, no mail,
  433. just send a tiff.  Efax is available as:
  434. `sunsite.unc.edu:/pub/Linux/apps/comm/efax05.tar.gz'
  435.  
  436. 2.6 *roff, man pages
  437. ====================
  438.  
  439.    Man pages can sometimes be printed straight from the cat pages (in
  440. lieu of the normal nroff source pages) as though they were a normal
  441. text file (which they mostly are).  However, many printers do not like
  442. the control characters for highlighting and what not that is imbedded
  443. in these.  A filter for this purpose comes with the net-2 lpd package.
  444.  
  445.    If you have the nroff source to the page (the finding of which I
  446. highly recommend) you can say `man -t foobar | lpr' and your man
  447. program will (hopefully) format the man page using groff into
  448. PostScript, which will then be sent to your lpd and on to the printer.
  449. This form of man page output looks MUCH better than the plain ASCII
  450. version.  Unfortunately, this depends very much on which man program
  451. and what supporting software you have installed.  If your man doesn't
  452. do this, you might try the perl version of man, available near:
  453. `sunsite.unc.edu:/pub/Linux/system/Manual-pagers/'
  454.  
  455.    It is written entirely in perl, and is thus easily customizable (perl
  456. being an interpreted language reminiscent of C and sh).
  457.  
  458.    You can also find the nroff source file in the man directories (most
  459. versions of man have an option to just spit out the filename) and do it
  460. yourself, into any format supported by groff.
  461.      groff -mandoc -TTYPE foobar.1 | lpr
  462.  
  463.    Where TYPE is one of `ascii', `dvi', `ps', `X100', `X75', `latin8'.
  464.  
  465. 2.7 Printing text via PostScript
  466. ================================
  467.  
  468.    There are a number of utilities to allow text to be printed to a
  469. PostScript device.
  470.  
  471. 2.7.1 mpage
  472. -----------
  473.  
  474.    The package mpage converts plain text into PostScript and/or prints
  475. more than one page onto each peice of paper given PostScript or text.
  476. It is available at (or at least near):
  477. `wuarchive.wustl.edu:/pub/mirrors/unix-c/PostScript/mpage.tar-z'
  478.  
  479.    Note that wuarchive uses the `-z' suffix to mean `.Z', ie,
  480. `compress', not `gzip' or `freeze'. `man -t foobar | mpage' will send a
  481. 2-up (depending on the environment variable MPAGE) version of the man
  482. page to lpr and its PostScript interpreter.  This saves paper and
  483. speeds up printing.
  484.  
  485. 2.7.2 a2ps
  486. ----------
  487.  
  488.    A2ps will take ASCII and turn it into a nice PostScript document with
  489. headers and footers and page numbers, printed two pages on one (or
  490. otherwise, if you say so).  A2ps does a very nice job at this.  It is
  491. available at the same place mpage is.  Not that if you have a deskjet,
  492. many n-up programs will run into trouble by trying to print in that last
  493. half-inch.
  494.  
  495. 2.7.3 enscript
  496. --------------
  497.  
  498.    Enscript is a program which does basically the same thing as a2ps.  I
  499. do not know where to get it.  It comes with most commercial Un*ces.
  500.  
  501.    A clone version of enscript is called nenscript, available on
  502. `sunsite.unc.edu' as:
  503. `/pub/Linux/system/Printing/nenscript-1.13++.bin.tar.z'
  504. `/pub/Linux/system/Printing/nenscript-1.13++.tar.z'
  505.  
  506. 2.7.4 gslp
  507. ----------
  508.  
  509.    Gslp is one of the uilities which comes with ghostscript 2.6.x and
  510. purports to do the same ascii => ps conversion as enscript and a2ps.  I
  511. have not used it, but the docs say that
  512.  
  513.      gs -q -sDEVICE=????? -dNOPAUSE -- gslp.ps TEXT.FILE [OPTIONS]
  514.  
  515.    should do the trick.  (`gslp.ps' is the actual program, which is
  516. written in PostScript.  Here it is run with the argument TEXT.FILE.
  517. PostScript is in many respects a programming language more than a mere
  518. printer command language.)  Further documentation is in the file
  519. `gslp.ps'.  There is a script file which does the above for you.
  520.  
  521. 2.8 PostScript utilities
  522. ========================
  523.  
  524.    Those of you who deal with large amounts of PostScript may wish for
  525. more utility programs.  There are probably millions of little programs
  526. which do things to your PostScript. A representative package of them
  527. may be found in:
  528. `achilles.doc.ic.ac.uk:/tex/inter/psutils/'
  529. `ftp.cs.psu.edu:/pub/src/psutil.tar.gz'
  530.  
  531.    These handle page selection, double-sided printing, booklet creation,
  532. etc.  Most large ftp sites (eg, `wuarchive.wustl.edu', `ftp.uu.uunet')
  533. will have many such packages to choose from.
  534.  
  535. 2.9 TeX/dvi
  536. ===========
  537.  
  538.    [La]TeX is the text formatting package used by many in the academic
  539. world and elsewhere.  TeX works much like any other compiler - source
  540. code is run through the program `tex' to become a `.dvi' file
  541. (analogous to an .o object file in C) which can be further manipulated
  542. to produce printed output (a "binary").  This manipulation of a dvi
  543. (DeVice Independant) file usually takes a little bit of doing.  It is
  544. well worth it; TeX's output is of professional quality.
  545.  
  546.    If all you are given is a file with a `.tex' ending, try either `tex
  547. file.tex' or `latex file.tex'.  One of these is bound to work.  Then
  548. you have a dvi.  (You may have to run it twice for indexing)
  549.  
  550.    For those in the real world who cannot afford a dvi understanding
  551. printer, it is usually necessary to convert the dvi something the
  552. printer understands. These programs may be run manualy but are often
  553. built into lpd filters. See Also: Writing lpd filters.
  554.  
  555. 2.9.1 `dvips'
  556. -------------
  557.  
  558.    `dvips' converts dvi into PostScript that you can pipe into
  559. ghostscript or send to a PostScript printer.  Most installations come
  560. with functioning installations of both TeX and `dvips'.  Typing `dvips
  561. -f1 file.dvi | lpr' will do it.  `dvips' responds to either command line
  562. arguments or a file `/usr/TeX/lib/tex/ps/config.ps' (in the usual TeX
  563. layout, at least) in which you can arrange to have dvips automatically
  564. send its output to `lpr'.  Thus `dvips file.dvi' will do everything
  565. that needs to be done.
  566.  
  567.    Note that some `.dvi''s may include PostScript graphics in the
  568. `dvips' stage rather than the TeX stage of the game; if they are not
  569. found, you will get a hole instead of a picture.  This follows
  570. naturally from the object file analogy above.  Usually, pre-made
  571. documentation in this form has a makefile or script to do everything for
  572. you.  The LILO documentation is an example of this.
  573.  
  574.    `dvips' has several interesting options; for example, `dvips -r1
  575. file.dvi' will print it out backwards.  We deskjet users love this one.
  576.  
  577. 2.9.2 `eps'
  578. -----------
  579.  
  580.    Eps is a program which converts dvi files directly into the standard
  581. Epson printer language; thus it is a dvi driver for epsons.  I beleive
  582. it supports MakeTeXPK, the automatic font rendering system used by many
  583. dvi drivers, and is available as:
  584. `sunsite.unc.edu:/pub/Linux/apps/tex/eps-061.tar.gz'
  585. `ftp.ctd.comsat.com:/pub/'
  586.  
  587.    Note that it is still coming out with new versions fairly often, so
  588. there may be a newer version than 061.
  589.  
  590. 2.9.3 `dvilj'
  591. -------------
  592.  
  593.    For LaserJet owners, there is a separate program that will take dvi
  594. and convert it directly into your printer's language (PCL).  It is
  595. called dvilj2p or dvilj, and if not on tsx or sunsite, is certainly
  596. available on ftp.uu.net.
  597.  
  598.    (Description by Nils Rennebarth)
  599.  
  600.      Its a nice driver, but a little out of fashion in the sense that
  601.      configuration (especially of font-paths) font-paths is not very
  602.      flexible and that it doesn't support virtual fonts (at least the
  603.      version 0.51 not).  The biggest advantage over the
  604.      dvips/ghostscript combo is that it uses downloadable fonts which:
  605.         * reduces data transmission to the printer drastically, which
  606.           makes the printer usable even on a serial line.
  607.  
  608.         * reduces printer-memory-requirements drastically. A standard
  609.           Laserjet with 512k memory is able to print almost every
  610.           TeX-document.
  611.  
  612.      It has support for double side printing and most options you
  613.      expect a driver to have. It compiles cleanly and worked flawlessly
  614.      on our diverse hardware here.
  615.  
  616. 2.10 texinfo
  617. ============
  618.  
  619.    This is the native documentation format of the GNU project.  Emacs
  620. can be coerced into producing an info file from TeXinfo, and TeX can
  621. produce nice printed documantation from the same file.  It is a bit of
  622. a stretch for both systems, but it works.  It is really just TeX source
  623. which expects the macro file `texinfo.tex' to be installed on your
  624. system.  Just do `tex FILENAME' twice (for index generation purposes),
  625. and you end up with a plain dvi file, to print or preview at your
  626. leisure.
  627.  
  628.    In Emacs, you can also do `M-x texinfo-format-buffer' to convert the
  629. texinfo file into an info file viewable with Emacs `M-x info' or an info
  630. viewer of your choice.
  631.  
  632.    There are also separate programs which read and format info from a
  633. texinfo file.  These are available in:
  634. `prep.ai.mit.edu:/pub/gnu/'
  635.  
  636. 2.11 Printing though a terminal
  637. ===============================
  638.  
  639.    Many terminals and terminal emulators support the connection of a
  640. printer.  The computer the terminal is conected to may then use a
  641. standard set of escape sequences to operate this printer.  DEC VT's and
  642. most other ANSI terminals should offer this capability.
  643.  
  644.    A simple shell script will enable you to print a text file using the
  645. printer connected to your terminal:
  646.  
  647.      #!/bin/csh -f
  648.      # Transparent printing on a vt100-compatible terminal.
  649.      echo -n \[5i ; cat $* ; echo -n \[4i
  650.  
  651.    If this script is called `vtprint', then `vtprint [FILENAME
  652. [FILENAME]]' will print file(s) (or stdin if no file were specified) on
  653. your printer.
  654.  
  655. 2.12 hardware and drivers
  656. =========================
  657.  
  658.    There are two ways the kernel driver may be used to run the parallel
  659. ports.  One, the original, is the polling driver.  The other is the
  660. interrupt driver.  In principle, the interrupt driver only deals with
  661. the port when it gets an interrupt and should therefore be more
  662. efficient.  In practice, people have found that it depends on the
  663. machine.  It probably doesn't make too much difference in most
  664. situations.
  665.  
  666.    For the polling driver, you may adjust its polling frequency with the
  667. program tunelp without kernel twiddling. The actual driver is in the
  668. kernel source file `lp.c'.
  669.  
  670.    To choose the interrupt driver rather than the polled, use the
  671. program tunelp to set it.  (tunelp is available on sunsite, or from the
  672. printing mail server.)  Just put the appropriate line in `/etc/rc.local'
  673.  
  674.    Seven is the usual "LPT1:" IRQ, 5 is usual for "LPT2:" for an AT
  675. class machine.  Note that if your printer is on lp0, the interrupt
  676. driver will probably not work.  The first parameter should already
  677. contain the correct i/o base address.  Many bios boot screens have this
  678. information if you need it.
  679.  
  680.    DOS uses a polling driver so if you find that your printer works in
  681. DOS but not in Linux then you should try the polling driver.
  682.  
  683.    `tunelp' is available from the printing mail server or:
  684. `sunsite.unc.edu:/pub/Linux/system/Printing/tunelp-1.0.tar.z'
  685.  
  686. 2.13 Printer device names
  687. =========================
  688.  
  689.    On an XT bus system `LPT1:' becomes `/dev/lp0' (major=6, minor=0),
  690. on an AT `LPT1:' becomes `/dev/lp1' (major=6, minor=1). To be more
  691. precise:
  692.  
  693.      Name Major Minor I/O address
  694.       lp0   6     0       0x3bc
  695.       lp1   6     1       0x378
  696.       lp2   6     2       0x278
  697.  
  698.    For a serial printer use the `/dev/ttyS?' (or `/devttys?', if you
  699. follow that scheme) device, not the `/dev/cua?'  device. The
  700. `/dev/ttyS?' devices have major 4; the `/dev/cua?' devices have major 5.
  701.  
  702. 3 LPR
  703. *****
  704.  
  705.    This chapter used to the the `lpd-FAQ' then it became part of the
  706. `Linux-FAQ' and now it is part of the Printing-HOWTO. Who knows where
  707. it will go next?
  708.  
  709. 3.1 Setting up print services
  710. =============================
  711.  
  712.    This section was originally writen Karl Auer <Karl.Auer@anu.oedu.au>
  713. 1/11/93 and has now been included here because it was felt that the
  714. Printing-HOWTO, being written in the style of a reference manual, was
  715. not doing its job properly, since it did not describe in a
  716. straightforward way what you need to do to set up print services on your
  717. Linux machine.
  718.  
  719.    So far it has been included with little modification and may
  720. replicate or even contradict information elsewhere in the HOWTO.  The
  721. overview it gives should nevertheless be very useful to those new to
  722. bsd print spooling.
  723.  
  724. 3.1.1 Remote Printing Vs. Local Printing
  725. ----------------------------------------
  726.  
  727.    Remote printing is allowing people to send print jobs to your
  728. computer from another computer. This will be needed if, for example,
  729. you are running as a server in a network, or if a printer attached to
  730. your machine is to be accessible from other Unix hosts.
  731.  
  732.    Local printing is allowing users on your machine to send print jobs
  733. to a printer attached to your machine.
  734.  
  735.    There is a third combination too - your own use of remote printing
  736. on other Unix machines. That is, where you wish to print on a printer
  737. that is not attached to your own computer.
  738.  
  739. 3.1.2 What You Need
  740. -------------------
  741.  
  742.    This document assumes you know how to edit a text file under Linux,
  743. and that you have a basic understanding of file ownership and
  744. permissions.
  745.  
  746.    It also assumes that you have your Linux system set up and running
  747. correctly.  In particular, if you are going to use remote printing your
  748. networking subsystems must be installed and operating correctly.
  749.  
  750.    Check out the man pages on the commands `chmod' and `chown' for more
  751. information.
  752.  
  753. 3.1.3 How Printing Works Under Linux
  754. ------------------------------------
  755.  
  756.    The simplest way to print under Unix (and thus under Linux) is to
  757. send the print data directly to the printer device. This command will
  758. send a directory listing to the first parallel printer (LPT1: in DOS
  759. terms):
  760.  
  761.      ls > /dev/lp0
  762.  
  763.    This method does not take advantage of the multitasking capabilities
  764. of Linux, because the time taken for this command to finish will be
  765. however long it takes the printer to actually physically print the
  766. data. On a slow printer, or a printer which is deselected or
  767. disconnected, this could be a long time.
  768.  
  769.    A better method is to spool the data. That is, to collect the print
  770. data into a file, then start up a background process to send the data
  771. to the printer.
  772.  
  773.    This is essentially how Linux works. For each printer, a spool area
  774. is defined.  Data for the printer is collected in the spool area, one
  775. file per print job.  A background process (called the printer daemon)
  776. constantly scans the spool areas for new files to print. When one
  777. appears, the data is sent to the appropriate printer or *despooled*.
  778. When more than one file is waiting to be printed, they will be printed
  779. in the order they were completed - first in, first out. Thus the spool
  780. area is effectively a queue, and the waiting jobs are often referred to
  781. as being "in the print queue", or "queued".
  782.  
  783.    In the case of remote printing, the data is first spooled locally as
  784. for any other print job, but the background process is told to send the
  785. data to a particular printer on a particular remote machine.
  786.  
  787.    The necessary information that the printer daemon needs to do its
  788. job - the physical device to use, the spool area to look in, the remote
  789. machine and printer for remote printing and so on - is all stored in a
  790. file called `/etc/printcap'. The details of this file are discussed
  791. below.
  792.  
  793.    In the discussions that follow, the term "printer" will be used to
  794. mean a printer as specified in `/etc/printcap'. The term "physical
  795. printer" will be used to mean the thing that actually puts characters on
  796. paper. It is possible to have multiple entries in `/etc/printcap' which
  797. all describe one physical printer, but do so in different ways. If this
  798. is not clear to you, read the section on `/etc/printcap'.
  799.  
  800. 3.1.4 The important programs
  801. ----------------------------
  802.  
  803.    There are five programs which comprise the Unix print system. They
  804. should be in the locations shown, should all be owned by root and
  805. belong to the group daemon and have the permissions shown here:
  806.  
  807.          -rwsr-sr-x    /usr/bin/lpr
  808.          -rwsr-sr-x    /usr/bin/lpq
  809.          -rwsr-sr-x    /usr/bin/lpc
  810.          -rwsr-sr-x    /usr/bin/lprm
  811.          -rwxr-s---    /etc/lpd
  812.  
  813.    The first four are used to submit, cancel and inspect print jobs.
  814. `/etc/lpd' is the printer daemon.
  815.  
  816.    (The locations, ownerships and permissions given here are a
  817. simplification and may be wrong for your system *note lpd files and
  818. permissions.)
  819.  
  820.    There are man pages for all these commands, which you should consult
  821. for more information. The important points are that by default `lpr',
  822. `lprm', `lpc' and `lpq' will operate on a printer called `lp'. If you
  823. define an environment variable called `PRINTER', the name thus defined
  824. will be used instead. Both these may be overridden by specifying the
  825. printer name to use on the command line thus:
  826.  
  827.      lpc -PMYPRINTER
  828.  
  829. 3.1.5 The `lpr' Command
  830. -----------------------
  831.  
  832.    The `lpr' command submits a job to the printer, or "queues a print
  833. job". What actually happens is that the file you specify is copied to
  834. the spool directory (see above), where it will be found by `lpd', which
  835. then takes care of moving the data to the physical printer. If you don't
  836. specify a file, `lpr' uses standard input.
  837.  
  838. 3.1.6 The `lpq' Command
  839. -----------------------
  840.  
  841.    The `lpq' command shows you the contents of the spool directory for
  842. a given printer. One important piece of information displayed by `lpq'
  843. is the job id, which identifies a particular job. This number must be
  844. specified if you wish to cancel a pending job.
  845.  
  846.    `lpq' also shows a rank for each job in the queue - "active" means
  847. the file is actually printing (or at least that `lpd' is trying to
  848. print it). Otherwise a number shows you where in the queue the job is.
  849.  
  850. 3.1.7 The `lprm' Command
  851. ------------------------
  852.  
  853.    The `lprm' command removes a job from the queue - that is, it
  854. removes unprinted files from the spool directory. You can either specify
  855. a job id (obtained by using the `lpq' command) or specify `-' as the
  856. job id, in which case all jobs belonging to you will be cancelled. If
  857. you do this as root, all jobs for the printer will be cancelled. If you
  858. are root and want to remove all the jobs belonging to a specific user,
  859. specify the user's name.
  860.  
  861. 3.1.8 The `lpc' Command
  862. -----------------------
  863.  
  864.    The `lpc' command lets you check the status of printers and control
  865. some aspects of their use. In particular it lets you start and stop
  866. despooling on printers, lets you enable or disable printers and lets you
  867. rearrange the order of jobs in a print queue. The following commands
  868. disable printing on myprinter, enable the spool queue on yourprinter and
  869. move job number 37 to the top of the queue:
  870.  
  871.      lpc down myprinter
  872.      lpc enable yourprinter
  873.      lpc topq 37
  874.  
  875.    If invoked without any command arguments, lpc will be interactive,
  876. prompting you for actions to take. Read the man page for complete
  877. instructions. Bear in mind that some `lpc' functions are restricted to
  878. root.
  879.  
  880. 3.1.9 The Important Directories
  881. -------------------------------
  882.  
  883.    There is really only one important directory - the spool area where
  884. data to be printed is accumulated before `/etc/lpd' prints it. However,
  885. typically a system will be set up with multiple spool directories, one
  886. for each printer. This makes printer management easier. My system is set
  887. up to use `/usr/spool/lpd' as the main spool area, with each separate
  888. printer having a directory under that with the same name as the
  889. printer. Thus I have a printer called `ps_nff' which has
  890. `/usr/spool/lpd/ps_nff' as its spool directory and so on.
  891.  
  892.    The spool directories should belong to the daemon group and be user
  893. and group read/writable, and world -readable. That is, after creating
  894. the directory make sure it has permissions "-rwxrwxr-x" (0775). For the
  895. directory myprinter, the appropriate command would be:
  896.  
  897.      chmod ug=rwx,o=rx myprinter
  898.      chgrp daemon myprinter
  899.  
  900.    (The locations, ownerships and permissions given here are a
  901. simplification and may be wrong for your system *note lpd files and
  902. permissions.)
  903.  
  904. 3.1.10 The Important Files
  905. --------------------------
  906.  
  907.    Apart from the programs discussed above, each spool directory should
  908. contain four files - `.seq', `errs'. `lock' and `status'. These files
  909. should have the permissions "-rw-rw-r-". The `.seq' file contains the
  910. job number counter for `lpr' to assign a and the `status' file contains
  911. the message to be reported by `lpc stat'. The `lock' file is used by
  912. `lpd' to prevent itself trying to print two jobs to the same printer at
  913. once, and the `errs' file is a log of printer failures.
  914.  
  915.    The file `errs' is not required and can actually be called whatever
  916. you like - the name is specified in `/etc/printcap', but the file must
  917. exist for `lpd' to be able to log to it, so it is usually created
  918. manually when setting up the spool area. More on this later.
  919.  
  920.    One very important file is the file `/etc/printcap', which is
  921. described in detail in the following sections.
  922.  
  923. 3.1.11 More About /etc/printcap
  924. -------------------------------
  925.  
  926.    The file `/etc/printcap' is a text file, which may be edited with
  927. your favourite editor. It should be owned by root and have the
  928. permissions "-rw-r-r-".
  929.  
  930.    The contents of `/etc/printcap' are typically very cryptic-looking,
  931. but once you know how it works they are much easier to understand. The
  932. problem is compounded by the fact that in some braindead distributions
  933. there is no man page for printcap, and the fact that most printcaps are
  934. created either by programs or by people with no thought for
  935. readability. For your own sanity, I recommend making the layout of your
  936. printcap file as logical and readable as possible, with lots of
  937. comments. And get the a man page from the lpd sources, if you don't
  938. already have it.
  939.  
  940.    One printcap entry describes one printer. Essentially a printcap
  941. entry provides a logical name for a physical device, then describes how
  942. data to be sent to that device is to be handled. For example, a printcap
  943. entry will define what physical device is to be used, what spool
  944. directory data for that device should be stored in, what preprocessing
  945. should be performed on the data, where errors on the physical device
  946. should be logged and so forth. You can limit the amount of data which
  947. may be sent in a single job, or limit access to a printer to certain
  948. classes of user.
  949.  
  950.    It is perfectly OK to have multiple printcap entries defining several
  951. different ways to handle data destined for the same physical printer.
  952. For example, a physical printer may support both PostScript and HP
  953. Laserjet data formats, depending on some setup sequence being sent to
  954. the physical printer before each job. It would make sense to define two
  955. printers, one of which preprocesses the data by prepending the HP
  956. LaserJet sequence while the other prepends the PostScript sequence.
  957. Programs which generate HP data would send it to the HP printer, while
  958. programs generating PostScript would print to the PostScript printer.
  959.  
  960.    Programs which change the data before it is sent to the physical
  961. printer are called "filters".  It is possible for a filter to send no
  962. data at all to a physical printer.
  963.  
  964.    See Also: The Syntax of /etc/printcap
  965.  
  966.      # Sample printcap entry with two aliases
  967.      myprinter|laserwriter:\
  968.          # lp is the device to print to - here the first parallel printer.
  969.          :lp=/dev/lp0: \
  970.          # sd means 'spool directory' - where print data is collected
  971.          :sd=/usr/spool/lpd/myprinter:
  972.  
  973. 3.1.12 Fields in `/etc/printcap'
  974. --------------------------------
  975.  
  976.    There are too many fields to describe here in full, so I'll just
  977. describe the most important ones. All fields in `/etc/printcap' (except
  978. for the names of the printer) are enclosed between a pair of colons and
  979. are denoted by a two-letter code. The two-letter code is followed by a
  980. value that depends on the type of field. There are three types of field
  981. - string, boolean and numeric See Also: The Syntax of /etc/printcap.
  982.  
  983.    The following fields are the most common and most important ones:
  984.  
  985.      lp      string          specify the device to print to, eg /dev/lp0
  986.      sd      string          specify the name of the spool directory for
  987.                              this printer
  988.      lf      string          specify the file to which errors on this
  989.                              printer are to be logged
  990.      if      string          specify the input filter name
  991.      rm      string          specify the name of a remote printing host
  992.      rp      string          specify the name of a remote printer
  993.      sh      boolean         specify this to suppress headers (banner pages)
  994.      sf      boolean         specify this to suppress end-of-job form feeds
  995.      mx      numeric         specify the maximum allowable print job size
  996.                              (in blocks)
  997.  
  998. 3.1.13 More on The `lp' Field
  999. -----------------------------
  1000.  
  1001.    If you specify `/dev/null' as the print device, all other processing
  1002. will be performed correctly, but the final data will go to the bit
  1003. bucket. This is rarely useful except for test printer configurations or
  1004. with weird printers See Also: Printers not in /dev. When you are setting
  1005. up a remote printer (that is, you have specified `rm' and `rp' fields),
  1006. you should specify `:lp=:'.
  1007.  
  1008.    Don't leave the field empty unless you are using a remote printer.
  1009. The printer daemon will complain if you don't specify a print device.
  1010.  
  1011. 3.1.14 More On The lf Field
  1012. ---------------------------
  1013.  
  1014.    Whatever file you specify should already exist, or logging will not
  1015. occur.
  1016.  
  1017. 3.1.15 More On The if Field
  1018. ---------------------------
  1019.  
  1020.    Input filters are programs which take print data on their standard
  1021. input and generate output on their standard output. A typical use of an
  1022. input filter is to detect plain text and convert it into PostScript.
  1023. That is, raw text is its input, PostScript is its output. See Also: Writing
  1024. lpd filters.
  1025.  
  1026.    When you specify an input filter, the printer daemon does *not* send
  1027. the spooled print data to the specified device. Instead, it runs the
  1028. input filter with the spooled data as standard input and the print
  1029. device as standard output. (For another use for input filters *note A
  1030. test printcap entry.).
  1031.  
  1032. 3.1.16 More On The `rm' and `rp' Fields
  1033. ---------------------------------------
  1034.  
  1035.    Sending your print data to a printer attached to another machine is
  1036. as simple as specifying the remote machine `rm' and the remote printer
  1037. `rp', and making sure that the print device field `lp' is empty. Note
  1038. that data will still be spooled locally before being transferred to the
  1039. remote machine, and any input filters you specify will be run also.
  1040.  
  1041. 3.1.17 More On The `sh' and `sf' Fields
  1042. ---------------------------------------
  1043.  
  1044.    Unless you have a lot of different people using your printer, you
  1045. will most likely not be interested in banner pages.
  1046.  
  1047.    Suppressing form feeds is most useful if your printer is typically
  1048. used for output from wordprocessing packages. Most WP packages create
  1049. complete pages of data, so if the printer daemon is adding a form feed
  1050. to the end of each job, you will get a blank page after each job. If the
  1051. printer is usually used for program or directory listings, however,
  1052. having that form feed ensures that the final page is completely ejected,
  1053. so each listing starts at the top of a new page.
  1054.  
  1055. This is Info file Printing-HOWTO.info, produced by Makeinfo-1.55 from
  1056. the input file printing.texinfo.
  1057.  
  1058.    A guide to printing and previewing files under the Linux operating
  1059. system.
  1060.  
  1061.    Copyright (C) 1994 by Grant Taylor and Brian McCauley
  1062.  
  1063. 3.1.18 More On The `mx' Field
  1064. -----------------------------
  1065.  
  1066.    This field allows you to limit the size of the print data to be
  1067. spooled. The number you specify is in BUFSIZE blocks (1K under Linux).
  1068. If you specify zero, the limit is removed, allowing print jobs to be
  1069. limited only by available disk space. Note that the limit is on the
  1070. size of the spooled data, *not* the amount of data sent to the physical
  1071. printer. If a user tries to exceed this limit the file is tuncated. The
  1072. user will see a message saying "lpr: <filename>: copy file is too
  1073. large".
  1074.  
  1075.    For text physical printers, this is useful if you have users or
  1076. programs that may deliberately or accidentally create excessively large
  1077. output, but in most cases is not really very applicable.
  1078.  
  1079.    For PostScript physical printers, the limit is not useful at all,
  1080. because a very small amount of spooled PostScript data can generate a
  1081. large number of output pages.
  1082.  
  1083. 3.1.19 A Test Printcap Entry
  1084. ----------------------------
  1085.  
  1086.    The following shell script is a very simple input filter - it simply
  1087. concatenates its input onto the end of a file in `/tmp' after an
  1088. appropriate banner. We specify this filter in our printcap entry and
  1089. specify `/dev/null' as the print device. The print device will never
  1090. actually be used, but we have to set it to something because otherwise
  1091. the printer daemon will complain.
  1092.  
  1093.      #!/bin/sh
  1094.      # This file should be placed in the printer's spool directory and
  1095.      # named input_filter. It should be owned by root, group daemon, and be
  1096.      # world executable (-rwxr-xr-x).
  1097.      echo ------------------------------------------------ >> /tmp/testlp.out
  1098.      date                                                  >> /tmp/testlp.out
  1099.      echo ------------------------------------------------ >> /tmp/testlp.out
  1100.      cat                                                   >> /tmp/testlp.out
  1101.  
  1102.    Here's the printcap entry. Notice the (reasonably) readable format
  1103. and the use of continuation characters on all but the last line:
  1104.  
  1105.      myprinter|myprinter: \
  1106.          :lp=/dev/null: \
  1107.          :sd=/usr/spool/lpd/myprinter: \
  1108.          :lf=/usr/spool/lpd/myprinter/errs: \
  1109.          :if=/usr/spool/lpd/myprinter/input_filter: \
  1110.          :mx#0: \
  1111.          :sh: \
  1112.          :sf:
  1113.  
  1114. 3.1.20 Putting It All Together
  1115. ------------------------------
  1116.  
  1117.    Putting all the above bits together, here is a step by step guide to
  1118. setting up a single printer on `/dev/lp0'. You can then extend this to
  1119. other printers.  You have to be root do do all this, by the way.
  1120.  
  1121.   1. Check the permissions and locations of `lpr', `lprm', `lpc', `lpq'
  1122.      and `lpd' See Also: The important programs.
  1123.  
  1124.   2. Create the spool directory for your printer, which we will call
  1125.      `myprinter' for now. Make sure both are owned by root, group
  1126.      daemon, and are user and group writeable, readonly for others
  1127.      (-rwxrwxr-x).
  1128.  
  1129.           mkdir /usr/spool/lpd /usr/spool/lpd/myprinter
  1130.           chown root.daemon /usr/spool/lpd /usr/spool/lpd/myprinter
  1131.           chmod ug=rwx,o=rx /usr/spool/lpd /usr/spool/lpd/myprinter
  1132.  
  1133.   3. In the directory `/usr/spool/lpd/myprinter', create the necessary
  1134.      files and give them the correct permissions and owner:
  1135.  
  1136.           cd /usr/spool/lpd/myprinter
  1137.           touch .seq errs status lock
  1138.           chown root.daemon .seq errs status lock
  1139.           chmod ug=rw,o=r .seq errs status lock
  1140.  
  1141.   4. Create the shell script input_filter in the directory
  1142.      `/usr/spool/lpd/myprinter'. Use the input filter given above. Make
  1143.      sure that the file is owned by root, group daemon, and is
  1144.      executable by anyone.
  1145.  
  1146.           cd /usr/spool/lpd/myprinter
  1147.           chmod ug=rwx,o=rx input_filter
  1148.  
  1149.   5. Create the file `/etc/printcap' if it doesn't already exist. Remove
  1150.      all entries in it and add the test printcap entry given above.
  1151.      Make sure the file is owned by root, and readonly to everyone else
  1152.      (-rw-r-r-).
  1153.  
  1154.   6. Edit the file `rc.local'. Add the line `/etc/lpd' to the end. This
  1155.      will run the printer daemon each time the system boots. It is not
  1156.      necessary to boot now though - just run it by hand:
  1157.           lpd
  1158.  
  1159.   7. Do a test print:
  1160.           ls -l | lpr -Pmyprinter
  1161.  
  1162.   8. Look in `/tmp' for a file called `testlp.out' - it should contain
  1163.      your directory listing.
  1164.  
  1165.   9. Edit `/etc/printcap'. Copy the myprinter entry, so you have two
  1166.      identical entries.
  1167.  
  1168.         * in the *first* entry, change both occurrences of `myprinter'
  1169.           to `testlp' in the first line only
  1170.  
  1171.         * in the *second* entry, change `/dev/null' to your real print
  1172.           device, eg., `/dev/lp0'
  1173.  
  1174.         * in the *second* entry, remove the `if' line completely
  1175.  
  1176.  10. Either reboot the system or kill the printer daemon and restart it.
  1177.      This is because the printer daemon only looks at the /etc/printcap
  1178.      file when it first starts up.
  1179.  
  1180.  11. Do a test print again - this one should come out on your physical
  1181.      printer!
  1182.           ls -l | lpr -Pmyprinter
  1183.  
  1184. 3.1.21 More On Remote Printing
  1185. ------------------------------
  1186.  
  1187.    In order for any other machines to print using your printers, their
  1188. names will have to be registered in either the file `/etc/hosts.equiv'
  1189. or `/etc/hosts.lpd'.  These are simple text files, one host name per
  1190. line.
  1191.  
  1192.    For preference, add hosts to `/etc/hosts.lpd'. `/etc/hosts.equiv' is
  1193. used to give far wider access rights, and should be avoided wherever
  1194. possible.
  1195.  
  1196.    You can restrict remote users either by group name (specify the
  1197. groups permitted using one or more rg fields in `/etc/printcap' -
  1198. `:rg=admin:' will restrict access to a printer to those users belonging
  1199. to the group admin.  You can also restrict access to those users with
  1200. accounts on your system, by specifying the boolean flag `:rs:' in your
  1201. `/etc/printcap'.
  1202.  
  1203. 3.1.22 The Fiddly Bits
  1204. ----------------------
  1205.  
  1206.    If all the above worked, you will now have two printers defined in
  1207. `/etc/printcap' - one called testlp, which appends output to
  1208. `/tmp/testlp.out', and one called myprinter which sends unmodified
  1209. output to the physical printer attached to `/dev/lp0'. Both share the
  1210. same spool directory. As an exercise, you might like to set up a
  1211. separate spool directory for the testlp printer.
  1212.  
  1213.    If your printer is a PostScript printer, it may not be able to handle
  1214. plain text. If this is the case, you'll need to set up a filter to
  1215. convert plain text to PostScript. An excellent freeware program called
  1216. nenscript is available which does just this. See Also: PostScript. If you
  1217. don't set up such a filter, you will have to make sure by other means
  1218. that the printer is sent only PostScript.
  1219.  
  1220.    You may like to add a line to your login script - or even to the
  1221. default user login script - which sets up a `PRINTER' environment
  1222. variable. Under bash, a suitable line would be `export
  1223. PRINTER=myprinter'. This will prevent people having to specify
  1224. `-Pmyprinter' every time they submit a print job.
  1225.  
  1226.    To add more printers, just repeat the above process with different
  1227. printer names. Remember you can have multiple printcap entries all using
  1228. the same physical device. This lets you treat the same device
  1229. differently, depending on what you call it when you submit a print job
  1230. to it.
  1231.  
  1232.    It is possible to "reuse" a printcap entry. If you specify your own
  1233. machine as the remote host and another printer in your printcap file as
  1234. the remote printer, you can effectively redirect print data from one
  1235. printer to another.  Remember if you use this technique that all the
  1236. data will be processed by all input filters in the chain and spooled for
  1237. each printer it goes through.
  1238.  
  1239.    Although you can specify as many aliases for a printer as you like,
  1240. it seems that for maximum usefulness the first two should be the same
  1241. and should be the "real" printer name. Many programs will only ever use
  1242. one of these two aliases.  The `lpc' command will only report on the
  1243. first alias, though `lpc', `lpr', `lprm' and `lpq' all understand any
  1244. alias.
  1245.  
  1246.    Rather than specify a maximum spool file size, you may want instead
  1247. to prevent spool files expanding to fill your disk, even temporarily.
  1248. To do so, put a file called minfree in each spool directory, specifying
  1249. the amount of disk space that must remain for spooling data to be
  1250. accepted. This file is a simple text file, containing the number of
  1251. blocks to be left free. Usually this file is a link to a file in the
  1252. main spool directory, as it is rare for different printers to have
  1253. different minimums.
  1254.  
  1255. 3.1.23 Troubleshooting
  1256. ----------------------
  1257.  
  1258.    Problem: You get a message saying "lpd: connect: No such file or
  1259. directory"
  1260.  
  1261.    Answer: The printer daemon `/etc/lpd' is not running. You may have
  1262. forgotten to add it to your `/etc/rc.local' file. Alternatively you did
  1263. add it, but haven't booted since. Add it and reboot, OR just run
  1264. /etc/lpd. Remember you have to be root to do this. See Also: lpd not
  1265. working.
  1266.  
  1267.    Problem: You get a message saying "Job queued, but cannot start
  1268. daemon".
  1269.  
  1270.    Answer: This often appears right after the "lpd: connect" message.
  1271. Same problem.
  1272.  
  1273.    Problem: You get a message saying "lpd: cannot create
  1274. <spooldir>/.seq".
  1275.  
  1276.    Answer: You have not created the spool directory specified in the
  1277. printcap entry or have misnamed it. An alternative (though much less
  1278. likely) answer is that you have too little disk space left.
  1279.  
  1280.    Problem: You get a message saying "lpr: Printer queue is disabled".
  1281.  
  1282.    Answer: As root, use `lpc enable <PRINTERNAME>' to enable the
  1283. printer. Note that as root, you can submit jobs even to a disabled
  1284. printer.
  1285.  
  1286.    Problem: You submit a print job, there are no error messages, but
  1287. nothing comes out on the physical printer.
  1288.  
  1289.    Answer: There could be many reasons. Make sure the physical printer
  1290. is switched on, selected, and physically connected to the device
  1291. specified in the `/etc/printcap' file. Use the `lpq' command to see
  1292. whether the entry is in the queue. If it is, then the device may be
  1293. busy, the printer may be down, or there may be an error on the printer.
  1294. Check the error log specified in the printcap entry for clues. You can
  1295. use the `lpc status' command to check whether the printer is down and
  1296. `lpc up <PRINTERNAME>' to bring it back up if it is (you need to be
  1297. root to do this).
  1298.  
  1299.    If after checking as suggested your print jobs still do not come out,
  1300. double check that any input filter you have specified is present in the
  1301. correct directory and has the correct permissions. If you are running
  1302. syslogd, you can look in your logs for messages from lpd. If you see log
  1303. entries saying "cannot execv <name of input filter>", then this is
  1304. almost certainly the problem.
  1305.  
  1306.    Another possibility is that your printer is a PostScript printer and
  1307. you are not sending PostScript to it. Most PostScript printers will
  1308. ignore non-PostScript data. You may need to install an appropriate
  1309. text-to-PostScript input filter.
  1310.  
  1311.    Lastly (and you'll feel really silly if this is the cause!) check
  1312. that your input filter actually generates output and that the output
  1313. device is not `/dev/null'.
  1314.  
  1315.    Problem: When remote printing, your jobs go into the remote queue
  1316. but never get physically printed.
  1317.  
  1318.    Answer: If you can, look at the entry for the remote printer in the
  1319. `/etc/printcap' file on the remote machine. It may be restricting your
  1320. access.  The `rg' field restricts access to members of a specific group
  1321. which you may not be in, and the `rs' field prevents access from users
  1322. without accounts on the remote machine, which you may not have.
  1323. Alternatively the printer on the remote machine may have been downed by
  1324. the system administrator. See Also: lpr over a network.
  1325.  
  1326.  
  1327. 3.2 What lpr and lpd do
  1328. =======================
  1329.  
  1330.    Most Un*x systems use `lpd' (or the System V variant `lp'), the line
  1331. printer daemon, and friends to spool print jobs and run them through
  1332. all needed filters.  While line printers are certainly on their way
  1333. out, spooling print jobs and running them through filters is definitely
  1334. a convenient thing.  Thus lpr.  (subliminal note: *PLEASE* find and
  1335. read the `lpr', `lpd', `printcap', `lpc', `lpq', and `lprm' man pages.
  1336. They are in the source dist of the net-2, if you haven't got them.)
  1337.  
  1338. 3.3 Getting hold of lpd
  1339. =======================
  1340.  
  1341.    Lpd and family are available in several places.  The new Linux net-2
  1342. package contains a working BSD-style lpd (although it has a couple of
  1343. bugs and Makefile installs the binaries with the wrong permissions).  I
  1344. now use this one with my stock 0.99pl14 kernel after following the
  1345. directions in Matt Welsh's Net-2 HOWTO to get my NET-2 going (you only
  1346. need loopback). Most people (and this document) consider this to be
  1347. *the* Linux lpd package. A slightly debugged version incorporating
  1348. patches from earlier releases of this HOWTO is also available in:
  1349. `tsx-11.mit.edu:/pub/linux/packages/net/new-net-2/lpd-590p?.tar.gz'
  1350.  
  1351.    Some of the prepackaged Linux distributions have a very poor record
  1352. with respect to having a working lpd packages so don't be shy of
  1353. getting a new one if you seem to be having trouble.
  1354.  
  1355.    Fans of the SysV lp package should consider getting plp (however this
  1356. HOWTO contains no information on that package)
  1357.  
  1358.    An lpd binary package which can be coaxed into working with the old
  1359. net things (pre 0.99pl10 kernel) may still be around but you'll probably
  1360. find it a bit shakey and you really should update your kernel.  Note a
  1361. subtle difference between the two versions: the old one placed lock
  1362. files and such in `/var/spool', while the net-2 version requires the
  1363. directory `/var/spool/lpd' to exist for its lock file.
  1364.  
  1365.    You will need to edit `/etc/printcap' to configure lpd to use your
  1366. printer. Setting up lpd to accept PostScript and print it is not very
  1367. difficult; simply make a shell script filter. See Also: Writing lpd
  1368. filters
  1369.  
  1370.    Setting up lpd correctly is definitely worth the trouble if you are
  1371. going to do any printing at all.  Of course, if all you ever print is
  1372. the occasional man page or instruction book, then you can probably get
  1373. by without it (but even then it's nice).
  1374.  
  1375.    Ghostscript 2.6.x also comes with a complicated script and utilities
  1376. to generate printcap entries and manage multiple types of queues for a
  1377. printer.  I have not tested these, but I assume they can be made to
  1378. work.  If you are in a large-scale environment with varied printing
  1379. needs, these may be worth a look.
  1380.  
  1381. 3.4 Where Do The Files Go And What Should Their Permissions Be?
  1382. ===============================================================
  1383.  
  1384.    There is quite a bit of variation between the various releases but
  1385. I'll try where possible to offer solutions that are universally
  1386. applicable. Start `lpd' in your `/etc/rc' or `/etc/rc.local' (usually
  1387. in `/etc/rc.local' after you start `syslogd' (if you use `syslogd')).
  1388.  
  1389.    Set the group fields of the file permissons/ownership as follows:
  1390.  
  1391.      -rwxr-sr--   1 root     lp          37892 Nov 19 23:32 /etc/lpd
  1392.      -rwxr-sr-x   1 root     lp          21508 Nov 19 23:32 /usr/bin/lpc
  1393.      -rwsr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpq
  1394.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lpr
  1395.      -rwxr-sr-x   1 root     lp          17412 Nov 19 23:32 /usr/bin/lprm
  1396.      -rwxr-xr-x   1 root     lp           2816 May 10 13:37 /usr/bin/lptest
  1397.      
  1398.      ...and for each of the spool directories listed in the sd fields of
  1399.      /etc/printcap...
  1400.      
  1401.      /var/spool/lpd:
  1402.      total 5
  1403.      drwxrwxr-x   2 root     lp           1024 May 18 23:00 .
  1404.      drwxr-xr-x  11 root     root         1024 Feb 19 20:56 ..
  1405.      -rw-rw-r--   1 root     lp              4 May 18 23:00 .seq
  1406.      -rw-rw-r--   1 root     lp             18 May 18 23:00 lock
  1407.      -rw-rw-r--   1 root     lp             25 May 18 23:00 status
  1408.  
  1409.    Note these 3 files are created by lpr and lpd so if you've never run
  1410. these they will be absent. With some versions of the lpd package you
  1411. had to touch them into being or they would be created with the wrong
  1412. permissions but this bug seems to have been fixed.
  1413.  
  1414.    In older versions the group id was `daemon' not `lp'. There's also a
  1415. named socket but `lpd' creates/deletes it as needed. Also you may find
  1416. the uid is sometimes set to `daemon' or `lp' rather than `root' but
  1417. this is of no consequence except on setuid binaries.
  1418.  
  1419.    These permissions are the most pedantic so don't be surprised if
  1420. your system works with different permissions. On the other hand if lpd
  1421. is not working for you and you have different permissions please try
  1422. these before mailing us or posting to usenet. (This may sound obvious
  1423. but you'd be amazed how much mail I've had from people with the
  1424. permissions set wrong).
  1425.  
  1426.    People tell me that `lpr' must be setuid(root) but I've not seen
  1427. evidence that this is really the case as long as the file permissions on
  1428. the spool queues are right. Still as far as I know `lpr' is designed to
  1429. be secure when installed setuid(root). This allows an alternative
  1430. (sloppy) approach: just make `lpr' and `lprm' setuid(root) then you can
  1431. almost forget the file permissions on the spool queues!
  1432.  
  1433.    You're free to choose different directories for the executables on
  1434. your system (notably `lpc' is usually in `/etc' (or `/usr/sbin') even
  1435. though it has commands that are useful to non-root). Of course since
  1436. you are free to do this it implies the person who made up your
  1437. distribution was also free to do so, so be carefull to make sure you
  1438. delete old components when you install new ones.
  1439.  
  1440.    The master lpd lock file is fixed at compile time to be
  1441. `/var/spool/lpd/lpd.lock' so you must have a `/var/spool/lpd directory'
  1442. even if you choose not to keep your spool queue there. In the older
  1443. binaries the lock file was `/usr/spool/lpd.lock' so this was not an
  1444. issue.
  1445.  
  1446.    My advise is to keep your primary spool queue in `/usr/spool/lpd' and
  1447. make `/var' a symlink to `usr' or keep it in `/var/spool/lpd' and make
  1448. `/usr/spool' a symlink to `../var/spool'. This gives the greatest
  1449. compatibility with the pathnames that are compiled into the various
  1450. distributed binaries. Note that having a separate `/var' filesystem
  1451. avoids the problem of your `/usr' filesystem filling up as a result of
  1452. stuff in spool queues.
  1453.  
  1454.    The main configuration file is `/etc/printcap'. Network printing also
  1455. uses `/etc/hosts.allow' and `/etc/hosts.lpd'.
  1456.  
  1457.    By now everyone should have libraries and binaries that look for
  1458. config files in `/etc'. If you chose to keep your configs somewhere else
  1459. (`/conf' or `/usr/etc' for example) then `/etc' must contain a symlink
  1460. to the real file. If you still have a system which looks for files in
  1461. `/usr/etc' or `/etc/inet' your system is way out of date and you should
  1462. upgrade.
  1463.  
  1464. 3.5 lpd not working
  1465. ===================
  1466.  
  1467.    If `ps ax' does not reveal a `lpd' then you daemon has died (or was
  1468. never started) - usually a sign that it couldn't create its lockfile,
  1469. or was unable to find `/etc/services'.  (This will happen if you tried
  1470. to start it before all your filesystems were mounted).
  1471.  
  1472.    If `lpr' works only for root then you've probably got a permission
  1473. problem.
  1474.  
  1475.    If you cant even `cat' files to the printer then you may be using
  1476. the wrong device name for the printer in `/etc/printcap' See Also: Printer
  1477. device names or you may need to fiddle with `tunelp'.  See Also: hardware
  1478. and drivers.
  1479.  
  1480.    If you get "jobs queued, but cannot start daemon" or "lpc: connect:
  1481. No such file or directory" while `lpd' is running then you are having
  1482. trouble with the socket connection to `lpd'. "start" in the context of
  1483. this error really means "wake". This problem has come and gone
  1484. thoughout the history of Linux - I don't really understand this but it
  1485. stems from an erroneous interaction between the networking stuff and
  1486. "Unix domain" (non-network) sockets. Usually it has only shown up when
  1487. the network is incorrectly configured. If you're not really on a
  1488. network it is usually adequate just to have the following somewhere in
  1489. your startup.
  1490.  
  1491.      ifconfig lo localhost
  1492.      route add localhost
  1493.  
  1494.    You'll also need to have the `/etc/hosts' file. There's no need to
  1495. run any daemons.
  1496.  
  1497.    There is second and much more understandable way to produce this
  1498. error - use a mixture of components from different releases of lpd that
  1499. use different names for the Unix domain socket (new stuff uses
  1500. `/tmp/.printer', obsolete stuff `/dev/printer'). (For some time SLS was
  1501. released this way).
  1502.  
  1503.    At the time of writing I am quite unable to reproduce this error - I
  1504. am using my debugged version of the net-2 lpd compiled with gcc-2.4.5
  1505. and libc-4.4.4 on kernel 0.99.14.
  1506.  
  1507. 3.6 Where Do I Get A Printcap For Printer Model xxxxx?
  1508. ======================================================
  1509.  
  1510.    This question is essentially meaningless so please don't ask it on
  1511. usenet See Also: The Semantics of /etc/printcap.
  1512.  
  1513. 3.7 The Semantics of `/etc/printcap'
  1514. ====================================
  1515.  
  1516.    Given the similarity in appearance and name between `/etc/termcap'
  1517. and `/etc/printcap' one could be forgiven for assuming that they
  1518. contain analogous infomation. This is not the case. Whereas
  1519. `/etc/termcap' contains informations about terminal *types* - (mostly
  1520. escape seqences) printcap contains information about *specific*
  1521. printers (like the directory that holds the spool queue, the device
  1522. name of the printer and what room it's in). The information about a
  1523. printer model's escape sequences and so on are held in the various
  1524. "filters" which are programs called by `lpd' to drive the printer.
  1525. `/etc/printcap' simply gives the locations of these filters.  For
  1526. details RTFM(printcap). [Alternatively the net-HOWTO has a summary of
  1527. some of the more important fields.]
  1528.  
  1529.    One last point - you should always specify `suppress header' `:sh:'
  1530. unless you have a *text* (not PostScript) printer and want banners. On
  1531. a text printer they are usually a waste of time and paper. On a
  1532. PostScript printer they usually stop your printer working.  See Also:
  1533. Burst/banner pages.
  1534.  
  1535. 3.8 The Syntax of `/etc/printcap'
  1536. =================================
  1537.  
  1538.    Ideally RTFM(termcap) (yes, I said *termcap*) but since most people
  1539. don't have TFM(termcap) here are the essentials.
  1540.  
  1541.    Lines starting with `#' are comments (as you might have guessed).
  1542.  
  1543.    For each printer usable from the `lpr' command on your system there
  1544. is one logical line in the file. For the sake of readability each
  1545. logical line may be spread over several physical lines by making the
  1546. last character on all but the last physical line a backslash.
  1547.  
  1548.    Each logical line has the following format:
  1549.  
  1550.      NAME1|NAME2|NAME3:STRING_CAPABILITY=STRING:\
  1551.             :NUMERIC_CAPABILITY#NUMBER:BOOLEAN_CAPABILITY:
  1552.  
  1553.    The leading spaces and colon on the second line are for readability
  1554. only.
  1555.  
  1556.    A printer can have as many names as you like but conventionally the
  1557. final name is used as a longhand description of the printer. (Still
  1558. people are free to say `lpr -P "grotty teletype in room 213"' if that's
  1559. the description you've given.) One of the names of your default printer
  1560. must be `lp'.
  1561.  
  1562.    The list of capabilities can be as long as needed and the order is
  1563. not significant. Each "capability" is denoted by a two character code.
  1564. (The name "capability" comes form the file format's termcap heritage -
  1565. parameter or attribute would be a more sensible terms.) [Note from Ross
  1566. Biro: capabilities with 3 character names don't work properly which is
  1567. why the serial port stuff in the old binaries failed.]  Capabilities
  1568. having string value and have a `=' delimiter between the capability
  1569. name and the value while those having a numeric value use a `#'
  1570. (actually they can use either a `#' or an `='). Boolean "capabilities"
  1571. are true if they appear in the list and false if they do not.
  1572.  
  1573.    Special characters in a string value can be expressed using
  1574. backslash-escaped sequences as in C; in addition, `\E' stands for ESC.
  1575. `^' is also a kind of escape character; `^' followed by CHAR stands for
  1576. the control-equivalent of CHAR.  Thus, `^a' stands for the character
  1577. control-a, just like `\001'. `\' and `^' themselves can be represented
  1578. as `\\' and `\^' respectively. `\:' for `:' seems to work but the
  1579. source code contains a warning that it can confuse the parser and
  1580. `\072' is a better idea.
  1581.  
  1582.    Example:
  1583.      lp|bam|Epson FX-80:lp=/dev/lp1:sd=/usr/spool/lp1:sh:mx#0:\
  1584.              :df=/usr/local/lib/magic-filter/lp.df:\
  1585.              :if=/usr/local/lib/magic-filter/lp.if:
  1586.  
  1587.    The printer's name is `lp' (this is the printer that `lpr' uses by
  1588. default). It's also known as `bam' or `"Epson FX-80"'.
  1589.  
  1590.    The printer is on `/dev/lp1' (aka AT-bus LPT1:). I don't want a burst
  1591. page. I don't want a file length limit. Files queued by `lpr -d' are
  1592. passed through `/usr/local/lib/magic-filter/lp.df' and those queued by
  1593. `lpr' through `/usr/local/lib/magic-filter/lp.lf'.
  1594.  
  1595.    See also the next section.
  1596.  
  1597. 3.9 An `/etc/printcap' gotcha
  1598. =============================
  1599.  
  1600.    Two `/etc/printcap' files can look identical and yet one works and
  1601. the other doesn't.
  1602.  
  1603.    See if `lpc stat' reports a printer called ` :'. The last character
  1604. on a continued line must be a backslash. If there are whitespace
  1605. characters after the backslash then it doesn't register the next line
  1606. as a continuation.
  1607.  
  1608. 3.10 The Minimum /etc/printcap
  1609. ==============================
  1610.  
  1611.    This is a silly question but it is frequently asked. The answer is
  1612. `lp:sh' (that's 6 bytes including the required linefeed character on
  1613. the end). To use this `/etc/printcap' you must make `/dev/lp' a symlink
  1614. to your printer and create your spool queue directory as
  1615. `/usr/spool/lpd'.  (You might think that if you wanted banner pages you
  1616. could loose the `:sh' but the termcap syntax requires at least one
  1617. capability per entry).
  1618.  
  1619. 3.11 How to prevent the `Staircase Effect'
  1620. ==========================================
  1621.  
  1622.    Un*x terminates each line of a file with a linefeed but not a
  1623. carriage return so taken literally a Un*x text file printed on an ASCII
  1624. device will start each line below the end of the previous line.  Some
  1625. printers can be set to treat "linefeed" as "carriage return, linefeed",
  1626. others can't. If yours can then do simply do that. If the printer
  1627. cannot be fixed create a shell script filter that reads:
  1628.  
  1629.      #!/bin/sh
  1630.      if [ "$1" = -c ]; then
  1631.        cat
  1632.      else
  1633.        sed -e s/$/^M/
  1634.      fi
  1635.      # the ``echo -ne'' assumes that /bin/sh is really bash
  1636.      echo -ne \\f
  1637.  
  1638.    Where `^M' is a carriage return character not a `^' followed by a
  1639. `M'.  To type `^M' in Emacs use the sequence `C-q C-m' and in vi use
  1640. `C-v C-m'.  Conventionally this script is called `/usr/lib/lpf'. If you
  1641. have more than one such script a better idea is to keep them in a
  1642. subdirectory, say `/usr/lib/lpd/'. The test of `$1' allows the
  1643. insertion of carriage returns to be switched off by `lpr -l'.
  1644.  
  1645.    Install this filter as the `if' filter by putting
  1646. `:if=/usr/lib/lpf:' (or whatever) in your `/etc/printcap' entry for the
  1647. printer.
  1648.  
  1649.    Alternatively your printer may have an escape sequence that will set
  1650. the way it handles linefeed characters. A simple filter that uses an
  1651. `echo -ne' command to send this sequence may be appropriate.
  1652.  
  1653.      #!/bin/sh
  1654.      # Filter for HP printers to treat LF as CRLF
  1655.      # the ``echo -ne'' assumes that /bin/sh is really bash
  1656.      echo -ne \\033\&k2G
  1657.      cat
  1658.      echo -ne \\f
  1659.  
  1660. 3.12 Resetting the printer between each file printed
  1661. ====================================================
  1662.  
  1663.    Either make your filters do it or define the `tr' "capability" in
  1664. `/etc/printcap' to be your printer's font reset command. For details of
  1665. the format of this string see the question on the format of printcap.
  1666. This may not work if a printout crashes in the middle of an escape
  1667. sequence - putting a lot of `^@' on the front may help but this
  1668. probably won't be enough it you were printing raster graphics when the
  1669. filter died.
  1670.  
  1671. 3.13 Preventing formfeed after each file printed
  1672. ================================================
  1673.  
  1674.    If you don't have an `if' specified in `/etc/printcap' then `lpd'
  1675. will automatically put a formfeed at the end of each file. If you're
  1676. using a filter then it's up to the filter to decide if it wants to put
  1677. a formfeed. To disable formfeed completely if you don't have an `if'
  1678. put `:ff=:' in your `/etc/printcap'.  But please note this suppresses
  1679. the formfeed that would usually be printed if a filter dies. If you
  1680. want formfeeds after text printouts but not on printouts printed with
  1681. `lpr -l' then create the following `if' filter:
  1682.  
  1683.      #!/bin/sh
  1684.      # the ``echo -ne'' assumes that /bin/sh is really bash
  1685.      cat
  1686.      if [ "$1" != -c ]; then
  1687.        echo -ne \\f
  1688.      fi
  1689.  
  1690.    If you want a formfeed after `lpr -l' to be optional you can misuse
  1691. the `-i' switch to suppress the formfeed with the following trick (after
  1692. all `lpr -i -l' would usually not be implemented).
  1693.  
  1694.      #!/bin/sh
  1695.      cat
  1696.      # use lpr -i -l to print raw without trailing formfeed
  1697.      if [ "$1" != -c -o "$4" = -i0 ]; then
  1698.        # the ``echo -ne'' assumes that /bin/sh is really bash
  1699.        echo -ne \\f
  1700.      fi
  1701.  
  1702. 3.14 Printing with lpd to a serial port
  1703. =======================================
  1704.  
  1705.    The first if lpd complains about "ioctl(TIOCEXCL)" being
  1706. unimplemented you need a version of lpd that doesn't care (eg.
  1707. lpd-590p2)
  1708.  
  1709.    There are two sets of flags which you will need to set, plus the baud
  1710. rate (Note: the `fc' flag setting seems to override the `br#'
  1711. capability, so be sure to set that correctly as well as the `br#'!).
  1712.  
  1713.    Each of the flags can have bits set and cleared. Clearing is done
  1714. first, so specify the clear flags (`fc#' and `xc#') before the set
  1715. flags (`fs' and `xs').
  1716.  
  1717.    Setting the `br#' capability is self-explanatory. Example: `br#9600'
  1718.  
  1719.    It is very easy to translate from `stty' settings to printcap flag
  1720. settings. If you need to, see the man page for stty now.
  1721.  
  1722.    Use stty to set up the printer port so that you can cat a file to it
  1723. and have it print correctly. Here's what `stty -a' looks like for my
  1724. printer port:
  1725.  
  1726.      dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2
  1727.      speed 9600 baud; rows 0; columns 0; line = 0;
  1728.      intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  1729.      eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
  1730.      lnext = ^V; min = 1; time = 0;
  1731.      -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  1732.      -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr
  1733.      -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel
  1734.      -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
  1735.      bs0 vt0 ff0
  1736.      -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop
  1737.      -echoprt -echoctl -echoke
  1738.  
  1739.    The only changes between this and the way the port is initialized at
  1740. bootup are `-clocal', `-crtscts', and `ixon'. Your port may well be
  1741. different depending on how your printer does flow control.
  1742.  
  1743.    Once you have your stty settings right, so that `cat file >
  1744. /dev/ttyS2' (in my case) sends the file to the printer, look at the file
  1745. `/usr/src/linux/include/linux/termios.h'. This contains a lot of
  1746. `#define's and a few structs (You may wish to cat this file to the
  1747. printer (you do have that working, right?) and use it as scratch paper
  1748. - I (Andrew Tefft <teffta@engr.dnet.ge.com> did!). Go to the section
  1749. that starts out
  1750.  
  1751.      /* c_cflag bit meaning */
  1752.      #define CBAUD   0000017
  1753.  
  1754.    This section lists the meaning of the `fc#' and `fs#' bits.  You
  1755. will notice that the names there (after the baud rates) match up with
  1756. one of the lines of stty output. Didn't I say this was going to be easy?
  1757.  
  1758.    Note which of those settings are preceded with a - in your stty
  1759. output. Sum up all those numbers (they are octal). This represents the
  1760. bits you want to *clear*, so the result is your `fc#' capability.  Of
  1761. course, remember that you will be setting bits directly after you
  1762. clear, so you can just use `fc#0177777' (I do).
  1763.  
  1764.    Now do the same for those settings (listed in this section) which do
  1765. not have a - before them in your stty output. In my example the
  1766. important ones are CS8 (0000060), HUPCL (0002000), and CREAD (0000200).
  1767. Also note the flags for your baud rate - mine is 0000015. Add those all
  1768. up, and in my example you get 0002275. This goes in your `fs#'
  1769. capability (`fs#02275' works fine in my example).
  1770.  
  1771.    Do the same with set and clear for the next section of the include
  1772. file, "c_lflag bits". In my case I didn't have to set anything, so I
  1773. just use `xc#0157777' and `xs#0'.
  1774.  
  1775.    Once your printcap is set up, try it out. If things don't work, see
  1776. the next section.
  1777.  
  1778. 3.15 cat works to the serial port, but not lpd (1)
  1779. ==================================================
  1780.  
  1781.    Generally getting lpd up and running is explained elsewhere, but if
  1782. you are having trouble with serial port settings you can prevent `lpd'
  1783. from trying to configure your port by treating you printer as one that
  1784. does not present a normal device interface. See Also: Printers not in
  1785. /dev.
  1786.  
  1787.   1. Set your printer (in your printcap) to `/dev/null1'. (`mknod
  1788.      /dev/null1 c 1 3' because you don't want `/dev/null' to be opened
  1789.      exclusively).
  1790.  
  1791.      remove the baud rate and flags settings from your printcap.
  1792.  
  1793.   2. Create a script such as this:
  1794.  
  1795.           #!/bin/sh
  1796.           echo if: $* >> /var/spool/lpd/results
  1797.           # /dev/lp is linked to /dev/ttyS2 which has the printer
  1798.           exec your-old-input-filter $* > /dev/lp
  1799.         ...or if you didn't have an old `if' installed...
  1800.           #!/bin/sh
  1801.           echo if: $* >> /var/spool/lpd/results
  1802.           cat > /dev/lp
  1803.           # the ``echo -ne'' assumes that /bin/sh is realy bash
  1804.           echo -en \\f > /dev/lp
  1805.  
  1806.      Make sure it's world-executable and world-readable. Try out your
  1807.      script (`/usr/lib/lpd/if < SOMEFILE') and see if it prints.
  1808.  
  1809.   3. Set the `if' capability in your printcap to call this script, e.g.
  1810.      `if=/usr/lib/lpd/if'
  1811.  
  1812.   4. Use stty to correctly set your port settings. Try to print now.
  1813.      You should be able to tell if things are being spooled, and things
  1814.      *should* be printed, if your manual testing of the `if' script
  1815.      works. But this is a kludge, so the idea is not to use the `if'
  1816.      script.
  1817.  
  1818.    Assuming the above method using the `if' filter works and that you
  1819. believe that you have specified what you think are the correct flags
  1820. and baud rate in printcap; check `stty -a < /dev/ttyS2' (or whatever
  1821. your printer port is).  If the settings are not correct, check your
  1822. flags against your printout from termios.h. If the settings are *way*
  1823. not correct, you may need a fixed lpd. The patch follows, and you can
  1824. probably see why it's needed :-) Note: this patch is reversed and has
  1825. already been applied (uh... unapplied :-) ) to lpd-590p2 so don't apply
  1826. it if you already have that version or later.
  1827.  
  1828.    (the patch is coming in just a sec)
  1829.  
  1830.    When I was setting mine up, I followed a sequence like this:
  1831.  
  1832.      lprm WHATEVER # (make sure queue is empty and lpd is running)
  1833.      stty CORRECT SETTINGS < /dev/ttyS2
  1834.      lpr SOMETHING SMALL
  1835.      stty -a < /dev/ttyS2  # (often had to ctrl-c out of this one)
  1836.      
  1837.      twiddle with flags
  1838.      
  1839.      lprm WHATEVER # make sure queue is empty again...
  1840.  
  1841.    Here's the patch (I it's reversed so apply it with `-R' - or, in
  1842. practice, by hand!):
  1843.  
  1844.      -------------------------------Cut Here-------------------------------------
  1845.      *** lpd-590/lpd/printjob.c  Thu Jul  8 20:56:59 1993
  1846.      --- lpd-590/lpd/printjob.c~ Sat Feb 27 09:07:01 1993
  1847.      ***************
  1848.      *** 1271,1277 ****
  1849.              }
  1850.        #ifdef LINUX
  1851.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  1852.      !       ttybuf.c_cflag |= FS;           /* not quite right! */
  1853.        #else
  1854.              ttybuf.sg_flags &= ~FC;
  1855.              ttybuf.sg_flags |= FS;
  1856.      --- 1271,1277 ----
  1857.              }
  1858.        #ifdef LINUX
  1859.              ttybuf.c_cflag &= ~FC;          /* not quite right! */
  1860.      !       ttybuf.c_cflag |= ~FS;          /* not quite right! */
  1861.        #else
  1862.              ttybuf.sg_flags &= ~FC;
  1863.              ttybuf.sg_flags |= FS;
  1864.      -------------------------------Cut Here-------------------------------------
  1865.  
  1866. 3.16 Printers that are not simple devices
  1867. =========================================
  1868.  
  1869.    [Firstly I'll explain the subject.] The most common example is a
  1870. printer that is connected via a network in some strange way.  For
  1871. example consider a printer connected to a host with which you can only
  1872. communicate via E-mail.
  1873.  
  1874.    To use such a printer through `lpr' the `lp' capability of the print
  1875. queue should be directed to a `/dev/null' type device (e.g. `mknod
  1876. /dev/null1 c 1 3') but not `/dev/null' itself as `lpd' opens the device
  1877. exclusively. Each filter must must explicitly uuencode and mail its
  1878. output.
  1879.  
  1880.    In more complex cases if you already have an `if' or `of' filter for
  1881. a strangely connected printer then other filters can pass their output
  1882. to/through this filter to avoid duplication of effort.  In this case
  1883. the `if' filter should usually be called with the `-c' switch to
  1884. minimise the further manipulations if performs.
  1885.  
  1886.    I've heard someone has had some success trying something like this
  1887. with Novell NetWare and the free mail transfer agent "Charon".
  1888.  
  1889. 3.17 Generating burst or banner pages
  1890. =====================================
  1891.  
  1892.    For a simple text printer (in particular not PostScript) and a
  1893. simple text banner simply take `:sh:' out of the printcap record. If you
  1894. want to prevent the banner comming out in whatever font was last used
  1895. on the printer then define the `tr' "capability" to be your printer's
  1896. font reset command.
  1897.  
  1898.    If you want a fancy customised banner (or have a PostScript printer)
  1899. leave `:sh:' in the printcap and make each of your filters print the
  1900. banner. All the information to put on the banner is included in the
  1901. filter's positional parameters.  RTFM(printcap) for details. [ If
  1902. you're using <B.A.McCauley@bham.ac.uk>'s magic-filter package then call
  1903. the code to print the banners from the config script. ]
  1904.  
  1905. 3.18 Spooling text to a PostScript printer
  1906. ==========================================
  1907.  
  1908.    You need a filter based on a program that converts ascii to
  1909. PostScript. The most well known of these is `enscript' but it's also
  1910. the hardest to find (being non-free). Others include `a2ps',
  1911. `nenscript', and `mpage'. See Also: Printing text via PostScript.
  1912.  
  1913. 3.19 Why graphics files are sometines truncated
  1914. ===============================================
  1915.  
  1916.    This is usually because you've got a limit set on the maximum size
  1917. file that can sit in the spool queue. Put `mx#0' in your printcap.
  1918.  
  1919. 3.20 Why `lpr -i' doesn't work
  1920. ==============================
  1921.  
  1922.    To get `lpr -i' to work you need a filter installed as `if' that
  1923. implements it.  The `-i' switch is simply passed on by `lpd' to the
  1924. filter.  The filter called `lpf' that comes with `lpd' supports this
  1925. feature but can only be used to print text.  If you whant to use this
  1926. program but still want your filter to do some printer specific
  1927. initialisation then write script thus:
  1928.  
  1929.      #!/bin/sh
  1930.      # My initialisation stuff goes here
  1931.      exec /usr/lib/lpf $*
  1932.  
  1933.    More reasonably you could have your filter script send the printer
  1934. left margin sequence.
  1935.  
  1936.      #!/usr/bin/perl
  1937.      # This example is in perl for a change because converting numbers
  1938.      # to characters is tricky in shell script
  1939.      
  1940.      for ($i=0; !($_ = $ARGV[$i]) || !/^-i([0-9])+/; $i++) {}
  1941.      
  1942.      print pack("cAc",27,"l",$1);
  1943.      
  1944.      while (<STDIN>) { print; }
  1945.  
  1946. 3.21 Why `lpr -p' doesn't work?
  1947. ===============================
  1948.  
  1949.    Because it's broken. `lpd' always thinks that the printer is 0
  1950. characters wide regardless of what `/etc/printcap' or the `lpr'
  1951. arguemnts say. The lpd-FAQ contained a patch but it has now been
  1952. applied to lpd-590p1 and later. (Appologies to anyone who wanted this
  1953. patch after the lpd-FAQ merged with printing-how.to. It was dropped in
  1954. the mistaken belief that a new release of lpd-590 was iminent).
  1955.  
  1956.    One other thing: `lpd' calls `pr' by full pathname so if you keep
  1957. `pr' somewhere different from `/usr/bin/pr' you will need a symlink.
  1958. (Where `lpd' expects to find `pr' may vary from version to version).
  1959.  
  1960. 3.22 `lpc' and `lpq' warning of missing daemons
  1961. ===============================================
  1962.  
  1963.    One `lpd' process runs all the time and it spawns children to handle
  1964. each printer as needed. The health of the master daemon is not
  1965. explicity reported by `lpc' but the absence of errors indicates that it
  1966. is healthy. See Also: lpd not working. The `lpc stat' command will
  1967. display the message "no daemon present" for each queue that is not
  1968. actually printing at the time - this is completely normal. If printing
  1969. has been disabled or the queue is empty then this is not an error
  1970. condition. `lpq' is even more alarmist and will say "Warning: no daemon
  1971. present". If the daemon is absent when the queue has entries and has
  1972. not been explicitly stopped then this warning probably indicates an
  1973. error in a filter. Fix the filter then use `lpd up QUEUE-NAME' to
  1974. restart it.
  1975.  
  1976.    Sometimes when shutting down a printer `lpc' will get confused and
  1977. try to kill a non existant daemon. This leads to irritating but harmless
  1978. error messages. In lpd-590p2 these are much rarer.
  1979.  
  1980. 3.23 Using `lpr' over a network
  1981. ===============================
  1982.  
  1983.    To print on the printer listed as `foo' in the printcap on machine
  1984. `bar.baz.net' from the machine `mine.baz.net' you put an entry like
  1985. this in your `/etc/printcap' (on `mine.baz.net'):
  1986.  
  1987.      foo:lp=:rm=bar.baz.net:rp=foo:sd=/usr/lpd/spool/foo:
  1988.  
  1989.    and, of course, create the spool directory `/usr/lpd/spool/foo'.
  1990.  
  1991.    There's no point specifying filters and the like in
  1992. `mine.baz.net:/etc/printcap' as it's the ones in
  1993. `bar.baz.net:/etc/printcap' that will get used.
  1994.  
  1995.    On the machine `bar.baz.foo', you need to put `mine.baz.net' on a
  1996. line by itself in either `/etc/hosts.equiv' or `/etc/hosts.lpd'; note
  1997. that putting it in `/etc/hosts.equiv' will allow for unauthenticated
  1998. logins as well as printing.  `/etc/hosts.lpd' is for printing only.
  1999.  
  2000.    The machines listed in `/etc/hosts.*' should be described canonical
  2001. names or numbers as lpd starts with the IP address and performs a
  2002. revervse DNS lookup to get the name. If you are not sure of cannonical
  2003. name you can just list all the names you know for a machine. (If you
  2004. have `dig' then the command `dig -x A.B.C.D' can be used to get the
  2005. canonical name of IP address A.B.C.D.)
  2006.  
  2007.    If the printer server is not nunning a BSD style spooler then it
  2008. should still be possible to get it to work but the authority files may
  2009. have a different names or formats. For example Chris Nystrom
  2010. <chrisn@medianet.com> found that he had to create a file on the remote
  2011. machine called `/usr/spool/lp/admins/lp/Systems' that listed his Linux
  2012. box's name. We do not know if this is a SYSV thing or something
  2013. exclusive to dynix/ptx 2.0.3 that he is using on his Sequent.
  2014.  
  2015.    If you can't get remote printing to work thrugh lpd you may be able
  2016. to simply use remote command exectution like this:
  2017.  
  2018.      rsh bar.baz.net "lp -dlp" < FILE
  2019.  
  2020.    This example would be for a remote system using a SYSV type printing
  2021. system on host `bar.baz.net'.
  2022.  
  2023. 3.24 Writing lpd filters
  2024. ========================
  2025.  
  2026.    In normal Un*x terminology, filters are just programs (so they must
  2027. have execute permission) that read a stream from their standard input
  2028. and write to their standard output.
  2029.  
  2030.    lpd filters are filters in the sense that thay read STDIN and write
  2031. to STDOUT, but are unusual in that they may assume that their standard
  2032. input is a random acess file file and may perform lseek() operations on
  2033. it.
  2034.  
  2035.    All lpd filters have a common command line syntax (or more often
  2036. simply ignore command line parameters). For details of the command line
  2037. parameters RTFM(printcap).
  2038.  
  2039.    If you want to write a shell script filter it must have a #!/bin/sh
  2040. (or perl or csh) header.  Here is the generic form of a filter to
  2041. accept PostScript.
  2042.  
  2043.      #!/bin/sh
  2044.      /PATH.../gs -q -dSAFER -dNOPAUSE -r??? -sDevice=?????? -sOutputFile=- -
  2045.  
  2046.    Place the full pathname of the script as one of the filters (but not
  2047. `of'!) parameter in the printcap for your printer.  I suggest putting
  2048. such scripts in `/usr/lib/lpd/'. It is also usual to keep filters in
  2049. the spool directories but this goes against normal practice of keeping
  2050. programs and data neatly apart.  (`-dSAFER' attempts to protect against
  2051. PostScript interpreter security holes, `-q' and `-dNOPAUSE' make it run
  2052. nonstop, and Device is the appropriate special file for your printer).
  2053.  
  2054.    Here is an Epson FX-80 dvi filter using ghostscript:
  2055.  
  2056.      #!/bin/sh
  2057.      /usr/TeX/bin/dvips -f | \
  2058.                    /usr/bin/gs -q -dSAFER -sDEVICE=eps9high -r120x216 \
  2059.                    -dNOPAUSE -sOutputFile=- -
  2060.  
  2061.    More tools useful for making filters are described elsewhere in this
  2062. document.
  2063.  
  2064. 3.25 Debuging lpd filters
  2065. =========================
  2066.  
  2067.    It's easier to debug filters if you test them in an immediate shell
  2068. before you install them. (If your filter makes use of its command line
  2069. arguments you'll have to specify them too).  `my-new-filter <FILE
  2070. >/dev/lp1'
  2071.  
  2072.    A trick most people find useful when testing filters that make use of
  2073. their command line arguments is to include `echo $* >>/tmp/filter-log'
  2074. near the top of the script.
  2075.  
  2076.    If the filter works when you test it but still doesn't work when
  2077. called by `lpd' then you may have forgotten the `#!/bin/sh' header. You
  2078. may also need to set PATH within the script since the daemon's PATH may
  2079. not have everything you need. Note also that the filter is run with
  2080. uid=daemon so any programs it calls sould be world executable.
  2081.  
  2082. 3.26 Output (`of') filters
  2083. ==========================
  2084.  
  2085.    Never use these. (Well strictly speaking there are circumstances but
  2086. you're unlikey to meet them). Recently (early '94) there has been a
  2087. spate of preople on c.o.l.help advokating the use of output filters.
  2088. Using `of' filters means that if a printout is queued while another is
  2089. already printing the 2 will be run together with a form-feed between.
  2090. Any printer initialisation or file type detection will therfore not be
  2091. performed for the second file and it will probably be printed
  2092. incorrectly. There are other more subtle ways in which output filters
  2093. can do unexpected things. IMHO: If using an output filter is the
  2094. answer, it was probably a silly question.
  2095.  
  2096. This is Info file Printing-HOWTO.info, produced by Makeinfo-1.55 from
  2097. the input file printing.texinfo.
  2098.  
  2099.    A guide to printing and previewing files under the Linux operating
  2100. system.
  2101.  
  2102.    Copyright (C) 1994 by Grant Taylor and Brian McCauley
  2103.  
  2104. 3.27 Getting filters for given printers
  2105. =======================================
  2106.  
  2107.    From: B.A.McCauley@bham.ac.uk (Brian McCauley)
  2108.  
  2109.    Because writing a filter usually takes about 10 minutes once you've
  2110. found the right program (`gs', `dvilj' etc.) there's little call for
  2111. ftp archives of printer filters but we are thinking of creating an
  2112. extensive example file to go with this document.
  2113.  
  2114.    If you already have a program to print, say, DVI on your printer by
  2115. some mechanism then making it into a filter is usually a matter of
  2116. writting trivial shell script See Also: Writing lpd filters. If the
  2117. program you are using insists on reading a names file as input see the
  2118. next question. Text mode filters are trivial too (see this HOWTO)
  2119. unless you want lpr to have a choice of fonts in which case they are
  2120. slightly harder than trivial.  You will probably want to insert and
  2121. `echo -ne' command at the beginning and end of your filter to set up
  2122. the font etc to your liking.
  2123.  
  2124. 3.28 Filters from programs that won't read STDIN
  2125. ================================================
  2126.  
  2127.    Some of the programs that are used in writing `lpd' filters are not
  2128. capable of taking their input from their standard input. For example
  2129. `dvilj2p' insists on a named file as its input (and what's more expects
  2130. one with a `.dvi' suffix) so do this:
  2131.  
  2132.      #!/bin/sh
  2133.      ln -s /proc/self/fd/0 /tmp/$$.dvi
  2134.      dvilj2p /tmp/$$
  2135.      rm /tmp/$$.dvi
  2136.  
  2137.    Note: If it wasn't for the fact that `dvilj2p' adds a `.dvi' suffix
  2138. you wouldn't need the temporary symlink and could just specify
  2139. `/proc/self/fd/0' directly. People who use this trick often usually
  2140. permanently `ln -s /proc/self/fd/0 /dev/stdin'. If you're highly
  2141. security concious and don't allow access to `/proc' you'll need to
  2142. create a temporary file.
  2143.  
  2144. 3.29 Having many filters
  2145. ========================
  2146.  
  2147.    Historically the `lpr' command was created to support a finite set
  2148. of possible file types. You can, in fact, use any of the filters for any
  2149. reason. If you're never going to use Benson Varian raster files you
  2150. could use the `-v' switch for GIF files. You could even use `-d' for
  2151. low res and `-v' for high res. Remember that if you create a filter for
  2152. a file format that takes a long time to process then your printer may
  2153. sit idle between print jobs even when there are things in the queue.
  2154.  
  2155.    If you are on a network remember that the filter setups go on the
  2156. print server.  One way to avoid running out of filter options is to
  2157. define several logical printers in `/etc/printcap' that all point to the
  2158. same physical one and put each filter in the `if' field of a different
  2159. printcap entry. This has the advantage that you can set the `PRINTER'
  2160. enviroment variable to choose your filter rather than having to specify
  2161. it on the command line each time. One small problem with this is that
  2162. you have no control over the order in which files from separate queues
  2163. are printed.
  2164.  
  2165.    Another (and these days more common) way to avoid running out of
  2166. possible types is to use magic filters.
  2167.  
  2168. 3.30 Magic Filters
  2169. ==================
  2170.  
  2171.    Magic filters deduce their input files' types from `magic numbers'
  2172. (distictive byte patterns at particular offsets).  Magic filters are
  2173. usually perl scripts, shell scripts or C programs that simply identify
  2174. the file type then call the appropriate non-magic filter. Blatent plug
  2175. :-) Brian has a generic magic filter bash script that selects the right
  2176. filter to use based on the output of the `file' command. With a
  2177. suitable magic filter (and 3 associated non-magic filters) you can do
  2178. things like:
  2179.  
  2180.      lpr -d file1.dvi file2.div.Z file3.ps file4.texinfo.gz
  2181.  
  2182.    (BTW confguring `lpr' to handle texinfo files is getting a bit
  2183. silly).
  2184.  
  2185.    This is now on the mailserver or at:
  2186. `tsx-11.mit.edu:pub/linux/sources/usr.bin/magic-filter-0.4.tar.gz'
  2187. (Although the release number will possibly change in future).
  2188.  
  2189.    `apsfilter' is a rather easier to use shell script that requires no
  2190. additional filters and which is pre-configured for HP compatible laser
  2191. printers. This is also available on the mailserver.
  2192.  
  2193.    An example written in C, which may be easily adapted to most
  2194. installations is available from the printing mail server as `lpr_if.c'.
  2195.  
  2196.    Magic filters should never specified as `of' as the output filter
  2197. only gets called once if a number of files are printed without a gap.
  2198. There are other more subtle problems too using `of'.
  2199.  
  2200.    IMHO (Brian) magic filters as `if' are inelegant as they may prevent
  2201. you, say, listing a PostScript or nroff file. (Most people disagree
  2202. with me on this point.)
  2203.  
  2204. 3.31 Magic Filter Examples
  2205. ==========================
  2206.  
  2207.    The following is an example of a magic shell script which should take
  2208. either PostScript or text and deal with it:
  2209.  
  2210.      #!/bin/sh
  2211.      # This is based on a script I received from Scott Doty and which was
  2212.      # written by Keith Walker.  Keith's script made use of the fact that
  2213.      # lpd passes options to if:
  2214.      #
  2215.      #  <if> -w<width> -l<length> -i<indent> -n <user> -h <host> <accountingfile>
  2216.      #
  2217.      # to print text out well at any size.  This one does not.  These options
  2218.      # are also handy if you want to do your own snazzy header page, much
  2219.      # like NeWSPrint from Sun does (although running PostScript through
  2220.      # the display server to get it interpreted is a bit much :)
  2221.      #
  2222.      #
  2223.      # gs will reset the printer anyway, so the this text setup doesn't matter.
  2224.      # setup should include the escape code for \n conversion, if applicable.
  2225.      #
  2226.      printf "<printer setup for text printing (escape codes, etc)>"
  2227.      
  2228.      read first_line
  2229.      first_two_chars=`expr $first_line : '\(..\)'`
  2230.      
  2231.      if [ "$first_two_chars" = "%!" ]; then # it's PostScript
  2232.      
  2233.              /usr/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=??????? -sOutputFile=- -
  2234.      
  2235.      else # it's plain text
  2236.      
  2237.              echo -n $first_line
  2238.              cat
  2239.              printf "\014"
  2240.      
  2241.      fi
  2242.  
  2243.    Note that for the paranoid, shell scripts run as someone other than
  2244. the user are sometimes a security hole, but this is not the case with
  2245. lpd filters as the script's environment is not under the control of the
  2246. potential cracker.
  2247.  
  2248. 4 Previewing
  2249. ************
  2250.  
  2251.    These sections describe various ways to preview things under Linux -
  2252. that is, how to view them in a way approximating their final form
  2253. without printing them out.
  2254.  
  2255. 4.1 ghostview
  2256. =============
  2257.  
  2258.    Ghostview, a companion program for `gs', previews PostScript on an X
  2259. display.  It also lets you select individual or ranges of pages from a
  2260. PostScript document to print using `lpr'.  The new version, 1.5, has
  2261. fixed a few glitches which never bothered me but may make a difference
  2262. to you.  It also calls `gs' with the `-dSAFER' option and has a few
  2263. more resource and command-line options relative to 1.4.1.  The real
  2264. installation is from:
  2265. `prep.ai.mit.edu:/pub/gnu/ghostview-XXX.tar.gz'
  2266.  
  2267.    It builds out of the box.  Ghostview requires `gs' to work.  The new
  2268. version of `gs', 2.6.x, will use X display fonts in an effort to
  2269. improve legibility at the low resolutions of a video monitor (a
  2270. previous failing of this pair relative to commercial display-PostScript
  2271. based systems).  This works very well for me at least, at the expense
  2272. of exact character positioning (X fonts have different widths).  In
  2273. fact, I thought that Ghostview looks better than Sun's pageview the
  2274. other day when I looked at the same page in oth programs side-by-side.
  2275. Ghostview/Ghostscript also has much more intelligent color handling
  2276. than pageview.  You might wish to let `gs' render some Type 1 fonts you
  2277. install instead of using platform fonts (or the awful fonts `gs' comes
  2278. with.  To do this while in Ghostview (or in any situation involving the
  2279. X11 driver), place `ghostscript.useExternalFonts: false' in your
  2280. `.Xdefaults' file, and the platform fonts will not be used.
  2281.  
  2282.    This is part of a message posted to gnu.ghostscript.bug by Tim
  2283. Theisen <ghostview@cs.wisc.edu>:
  2284.      (note that the usual Linux X-server, XFree, is simply an enhanced
  2285.      version of MIT's effort at an i386 X-server (X386), and does
  2286.      contain the X11R5 Type 1 rasterizer which I beleive was
  2287.      contributed by IBM.)
  2288.  
  2289.      Ghostscript now uses the X Toolkit to pick up X Resources.  Now
  2290.      ghostscript uses the standard X rules that allow more specific
  2291.      resources to override less specific ones giving users the full
  2292.      power of X resources to control the X11 driver.  It also allows
  2293.      system administrators to establish an application defaults file
  2294.      with resources specific to their ghostscript installation.
  2295.  
  2296.      The customization choices mentioned in make.doc have been moved
  2297.      into X resources and are now configured at run time rather than
  2298.      compile time.  Sorry, this section of make.doc did not get revised
  2299.      for the 2.6.1 release.
  2300.  
  2301.      If `useBackingPixmap' is set, ghostscript will attempt to allocate
  2302.      a backing pixmap.  If one cannot be allocated, ghostscript will
  2303.      issue a warning and ask for backing store instead.  (Since there
  2304.      were insufficient resources for a backing pixmap, the X server may
  2305.      not provide backing store either.)
  2306.  
  2307.      Color Handling was totally revamped for gs 2.6.
  2308.  
  2309.      Ghostscript first checks for a suitable standard colormap.  If you
  2310.      have static colormap in your X server, it would be best to store a
  2311.      standard colormap property on the root window describing the color
  2312.      layout.  Ghostscript will then be able to take full advantage of
  2313.      the device.  If you have a standard colormap installed,
  2314.      ghostscript will start slightly faster since it does not have to
  2315.      allocate colors for a cube or ramp.
  2316.  
  2317.      If no standard colormap is available, ghostscript will allocate an
  2318.      RGB cube or gray ramp.  Ghostscript tries for a 5x5x5 cube on a
  2319.      color device, and a 128 gray ramp on grayscale devices.  It will
  2320.      never ask for more than 1/2 of the colors for a RGB cube or gray
  2321.      ramp.  It also takes into account the number of significant bits
  2322.      per pixel.  (i.e.  It won't ask for 128 gray levels if you only
  2323.      have 16 available.)
  2324.  
  2325.      Ghostscript will attempt to allocate colors that are off the color
  2326.      cube/ramp as the picture is being rendered.  Ghostscript will keep
  2327.      track of 256 dynamic colors.  After all these are allocated,
  2328.      ghostscript asks the X server directly.
  2329.  
  2330.      The foreground and background color can be set explicitly.  This
  2331.      is important for the visually impaired and when using the ghostview
  2332.      widget.
  2333.  
  2334.      Color Resources:
  2335.  
  2336.        1. `palette'(`Palette'): Default value: `Color'.  Other
  2337.           allowable settings: `Grayscale', `Monochrome'.  The palette
  2338.           resource is used to restrict the palette used for display.
  2339.           One can set palette to `Grayscale' or `Monochrome' to see how
  2340.           a file would be rendered in grayscale or monochrome on a
  2341.           color display.  I use it to avoid dithering of gray- scale
  2342.           figures on a color display with 4-bit DACs.
  2343.  
  2344.        2. `maxGrayRamp'(`MaxGrayRamp'): Default value: 128.  Maximum
  2345.           number of gray levels that ghostscript will attempt to
  2346.           allocate.  (It won't try for more than this on an 8-bit
  2347.           pseudo color display even if you set it higher.)  Set this
  2348.           lower if you want a smaller ramp and would prefer ghostscript
  2349.           to use dynamic colors.
  2350.  
  2351.        3. `maxRGBCube'(`MaxRGBCube'): Default value: 5.  Maximum number
  2352.           of colors levels that ghostscript will attempt to allocate.
  2353.           (It won't try for more than this on an 8-bit pseudo color
  2354.           display even if you set it higher.)  Set this lower if you
  2355.           want a smaller ramp and would prefer ghostscript to use
  2356.           dynamic colors.
  2357.  
  2358.      I believe these values to be a good compromise between dynamic
  2359.      allocation and fall back onto a fairly good color cube for
  2360.      dithering.
  2361.  
  2362.      You can use the foreground and background colors to accomplish
  2363.      "reverse video".  However, if you have a grayscale device, it may
  2364.      be better to reverse the gray ramp using the following PostScript
  2365.      code fragment:
  2366.  
  2367.           [{1 exch sub} /exec load currenttransfer /exec load] cvx settransfer
  2368.  
  2369.      The X11 driver now supports native X11 fonts.  If you have
  2370.      installed the HP XLFD font extensions into your font or X server.
  2371.      Ghostscript will also be able to use platform fonts at rotations
  2372.      of 90 degrees, with mirroring, and anamorphic scaling.
  2373.  
  2374.      The X11 driver does most if its work silently.  You can get it to
  2375.      report when it is using an X11 font by setting the logExternalFonts
  2376.      boolean in your X resources.
  2377.  
  2378.      The X11 driver is setup to use the standard fonts distributed with
  2379.      X11R5.  We purchased the Adobe Type Manager and the Adobe Plus
  2380.      Pack.  These font packages give all the fonts normally found in
  2381.      the Apple LaserWriter Plus.  The X11 driver is setup to handle
  2382.      these fonts as well.  (They are a superset of the bitmap fonts
  2383.      distributed with X11.)
  2384.  
  2385.      You may set the regularFonts, symbolFonts, or dinbatFonts resources
  2386.      if you have different fonts available.  Each font name must have 7
  2387.      dashes or it will be ignored.  Minimize the use of wildcards to
  2388.      promote faster matching.  (I once encountered an X server that took
  2389.      many seconds to do a font lookup when wildcards were carelessly
  2390.      used.)
  2391.  
  2392.      There is a different list of fonts for each common encoding.
  2393.      Regular fonts may be accessed in standard or ISO Latin 1 encoding.
  2394.      The bdf files that are distributed with X11 are in the ISO Latin
  2395.      1 encoding.  This leaves out the ligatures.  Luckily, the
  2396.      ligatures are present in the bdf files, but are not given an
  2397.      encoding, essentially commenting them out.  You can use the
  2398.      `fixfont' program from the xproof distribution
  2399.      (`Ftp.Cs.Wisc.Edu:/Pub/X/Xproof.Tar.Z', or
  2400.      `Ftp.X.Org:/Contrib/Xproof.Tar.Z') to reencode the bdf files and
  2401.      build X11 fonts that contain the ligatures (i.e standard encoding).
  2402.  
  2403.      If you have the Type1 fonts mentioned above, and you installed the
  2404.      Type1 rasterizer into you font or X server, you can use the
  2405.      appended fonts.scale to name your fonts so that ghostscript can
  2406.      find them.
  2407.  
  2408.      Font resources:
  2409.  
  2410.        1. `useExternalFonts'(`UseExternalFonts'): Default value: true.
  2411.           This resource controls whether X11 fonts will be used.
  2412.  
  2413.        2. `useScalableFonts'(`UseScalableFonts'): Default value: true.
  2414.           This resource controls whether scalable fonts will be used.
  2415.           If you have an outline scaler in your X server, you should
  2416.           have this on.  If you have an X terminal, you may get
  2417.           slightly better performance with this on.  If you have to use
  2418.           the X11 bitmap scaler, turn this off.  Fonts scaled by the
  2419.           bitmap scaler look worse than the default ghostscript fonts.
  2420.  
  2421.        3. `logExternalFonts'(`LogExternalFonts'): Default value: false.
  2422.           Controls whether to report when X11 fonts are being used.
  2423.  
  2424.      The following fonts.scale makes all of the fonts of the Adobe Type
  2425.      Manager and Adobe Plus pack available in standard and ISO Latin 1
  2426.      encoding.  (We were able to purchase the above two packages at an
  2427.      educational discount price of $150.)
  2428.  
  2429. 70
  2430. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-iso8859-1
  2431. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-iso8859-1
  2432. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  2433. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-iso8859-1
  2434. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-iso8859-1
  2435. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-iso8859-1
  2436. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-iso8859-1
  2437. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-iso8859-1
  2438. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-iso8859-1
  2439. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-iso8859-1
  2440. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-iso8859-1
  2441. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-iso8859-1
  2442. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2443. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-iso8859-1
  2444. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  2445. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-iso8859-1
  2446. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-iso8859-1
  2447. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-iso8859-1
  2448. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-iso8859-1
  2449. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-iso8859-1
  2450. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2451. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  2452. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  2453. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  2454. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2455. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  2456. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  2457. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  2458. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2459. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2460. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  2461. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-iso8859-1
  2462. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-iso8859-1
  2463. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-iso8859-1
  2464. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-iso8859-1
  2465. agw_____.pfb -Adobe-ITC Avant Garde Gothic-Book-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2466. agwo____.pfb -Adobe-ITC Avant Garde Gothic-Book-o-normal--0-0-0-0-p-0-adobe-fontspecific
  2467. agd_____.pfb -Adobe-ITC Avant Garde Gothic-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2468. agdo____.pfb -Adobe-ITC Avant Garde Gothic-Demi-o-normal--0-0-0-0-p-0-adobe-fontspecific
  2469. bkl_____.pfb -Adobe-ITC Bookman-Light-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2470. bkli____.pfb -Adobe-ITC Bookman-Light-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2471. bkd_____.pfb -Adobe-ITC Bookman-Demi-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2472. bkdi____.pfb -Adobe-ITC Bookman-Demi-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2473. com_____.pfb -Adobe-Courier-Medium-r-normal--0-0-0-0-m-0-adobe-fontspecific
  2474. coo_____.pfb -Adobe-Courier-Medium-o-normal--0-0-0-0-m-0-adobe-fontspecific
  2475. cob_____.pfb -Adobe-Courier-Bold-r-normal--0-0-0-0-m-0-adobe-fontspecific
  2476. cobo____.pfb -Adobe-Courier-Bold-o-normal--0-0-0-0-m-0-adobe-fontspecific
  2477. hv______.pfb -Adobe-Helvetica-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2478. hvo_____.pfb -Adobe-Helvetica-Medium-o-normal--0-0-0-0-p-0-adobe-fontspecific
  2479. hvb_____.pfb -Adobe-Helvetica-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2480. hvbo____.pfb -Adobe-Helvetica-Bold-o-normal--0-0-0-0-p-0-adobe-fontspecific
  2481. hvn_____.pfb -Adobe-Helvetica-Medium-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  2482. hvno____.pfb -Adobe-Helvetica-Medium-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  2483. hvnb____.pfb -Adobe-Helvetica-Bold-r-Narrow--0-0-0-0-p-0-adobe-fontspecific
  2484. hvnbo___.pfb -Adobe-Helvetica-Bold-o-Narrow--0-0-0-0-p-0-adobe-fontspecific
  2485. ncr_____.pfb -Adobe-New Century Schoolbook-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2486. nci_____.pfb -Adobe-New Century Schoolbook-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2487. ncb_____.pfb -Adobe-New Century Schoolbook-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2488. ncbi____.pfb -Adobe-New Century Schoolbook-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2489. por_____.pfb -Adobe-Palatino-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2490. poi_____.pfb -Adobe-Palatino-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2491. pob_____.pfb -Adobe-Palatino-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2492. pobi____.pfb -Adobe-Palatino-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2493. sy______.pfb -Adobe-Symbol-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2494. tir_____.pfb -Adobe-Times-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2495. tii_____.pfb -Adobe-Times-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2496. tib_____.pfb -Adobe-Times-Bold-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2497. tibi____.pfb -Adobe-Times-Bold-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2498. zcmi____.pfb -Adobe-ITC Zapf Chancery-Medium-i-normal--0-0-0-0-p-0-adobe-fontspecific
  2499. zd______.pfb -Adobe-ITC Zapf Dingbats-Medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
  2500.  
  2501. 4.2 gspreview
  2502. =============
  2503.  
  2504.    This is another front-end for Ghostscript.  I have gotten and built
  2505. it, and actually preferred the user interface, but it had a few bugs.
  2506. It didn't seem as full-featured as ghostview, though.  (Not that there
  2507. are all *that* many features in ghostview, but it does its job well).
  2508. `ftp.x.org:/contrib/gspreview...'
  2509.  
  2510. 4.3 xdvi
  2511. ========
  2512.  
  2513.    A beautifully legible previewing program for dvi with a handy
  2514. zoom+pan feature.  Will not interpret PostScript specials, which are
  2515. understood only by `dvips' (back to the compiler, object file, and now
  2516. linker analogy :-)  To view a file, do `xdvi file.dvi'.  This comes
  2517. with either TeX or X in most distributions.  Either way, you've
  2518. probably got one.  If not, look in `ftp.x.org:/contrib/'.
  2519.  
  2520. 4.4 xtex
  2521. ========
  2522.  
  2523.    Xtex is similar in purpose to xdvi.  I have tried to build it under
  2524. Linux and failed.  It is available as:
  2525. `ftp.x.org:/contrib/xtex-2.18.5.tar.z'
  2526.  
  2527. 4.5 gxditview
  2528. =============
  2529.  
  2530.    Ditview produces a preview version of `troff' source using X fonts.
  2531. `groff -TX100 -mandoc MAN PAGE' will run gxditview to show you a
  2532. typeset version of the man page.  `-TX75' is the same thing, but tiny.
  2533. Most distributions don't have a working one at all.  A good one comes
  2534. with the source to `groff', which you might want to get anyway for the
  2535. additional drivers (some distributions are missing some, including
  2536. PostScript).
  2537. `prep.ai.mit.edu:/pub/gnu/groff-XXXX.tar.z'
  2538.  
  2539. 4.6 non-X previewing
  2540. ====================
  2541.  
  2542.    Ghostscript comes with pc video hardware drivers, but under un*x
  2543. these are not a good thing.  However, there are `gs' binaries around
  2544. which will use the Linux VGA library (`svgalib').  The Ghostscript
  2545. device for this is called linux, thus `gs -sDEVICE=linux file.ps' will
  2546. show you an image of the PostScript.  The environment variable
  2547. `GSVGAMODE' is important for this.  Set it to the nuber of the video
  2548. mode you want, taken from the vga.h which comes with vgalib.
  2549.  
  2550.    If you need this driver, a patch to put in Linux svgalib is available
  2551. from the printing mail server or as:
  2552.      ws105.zfn.uni-bremen.de:/pub/gs261-linuxdriver.sh
  2553.      ws105.zfn.uni-bremen.de:/pub/gs261-svgalib.tar.gz
  2554.  
  2555.    Another possibly different svgalib patch is found in:
  2556. `ftp.cdrom.com:/pub/linux/misc'
  2557.  
  2558.    The plain vgalib driver is available on Sunsite.
  2559.  
  2560.    Texmgr is a program which will preview dvi under MGR.  I don't
  2561. beleive that it currently works under Linux MGR, but if it does, MGR
  2562. uses sufficiently less memory and disk that this might be an attractive
  2563. option for some.
  2564.  
  2565.    dvgt is a program which will preview dvi with Linux svgalib, or on
  2566. one of several types of graphics terminals including vt, tek, or a PC
  2567. with MS-Kermit.  It is available on sunsite.
  2568.  
  2569. 5 Ascii Translation
  2570. *******************
  2571.  
  2572.    These sections describe various programs which can generate plain
  2573. ascii from some file formats.
  2574.  
  2575. 5.1 from TeX
  2576. ============
  2577.  
  2578.    Lametex will generate ascii from TeX source.  It is available as:
  2579. `sunsite.unc.edu:/pub/Linux/apps/tex/lametex.tar.z'
  2580.  
  2581.    LaTeX is used by the Linux Doc Projext to generate text versions of
  2582. their manuals.  I don't know where to find it.
  2583.  
  2584. 5.2 from dvi
  2585. ============
  2586.  
  2587.    `dvi2tty' is a program which will process dvi into text.  Aparently,
  2588. it will also make an effort at reproducing graphics as well.  I do not
  2589. know where to find it.
  2590.  
  2591. 5.3 from PostScript
  2592. ===================
  2593.  
  2594.    Ghostscript 2.6.1 comes with a script file which will use `gs' to
  2595. extract just the text from a ps file, called `ps2ascii'.  (*note
  2596. PostScript., for information above for where it can be found).
  2597. Further documentation is in the Ghostscript 2.6.1 distribution files
  2598. `gs_2asc.ps' and `use.doc'
  2599.  
  2600. 5.4 from troff
  2601. ==============
  2602.  
  2603.      groff -Tascii or -Tlatin1 ...
  2604.  
  2605. 5.5 from ascii/latin1
  2606. =====================
  2607.  
  2608.    The GNU program `recode' handles conversion between various forms of
  2609. straight text encoding, ie from Latin-1 to ASCII.  This is available on
  2610. prep.ai.mit.edu.
  2611.  
  2612. --
  2613. Unless otherwise stated, Linux HOWTO documents are copyrighted by their
  2614. respective authors. Linux HOWTO documents may be reproduced and distributed 
  2615. in whole or in part, in any medium physical or electronic, without permission 
  2616. of the author. Translations and derivative works are similarly permitted 
  2617. without express permission. Commercial redistribution is allowed and 
  2618. encouraged; however, the author would like to be notified of any such 
  2619. distributions. 
  2620.  
  2621. In short, we wish to promote dissemination of this information through as
  2622. many channels as possible. However, we do wish to retain copyright on the
  2623. HOWTO documents, and would like to be notified of any plans to redistribute
  2624. the HOWTOs. If you have questions, please contact Matt Welsh, the Linux
  2625. HOWTO coordinator, at mdw@sunsite.unc.edu.
  2626.